Assembly: soss_namedcache (in soss_namedcache.dll) Version: 188.8.131.52
public static R ForEach<T, P, R>( this IQueryable<T> source, P param, Func<R> localInit, Func<T, P, R, R> body, Func<R, R, R> merge )
<ExtensionAttribute> Public Shared Function ForEach(Of T, P, R) ( source As IQueryable(Of T), param As P, localInit As Func(Of R), body As Func(Of T, P, R, R), merge As Func(Of R, R, R) ) As R
- Type: System.LinqIQueryable
An enumerable source of data stored in the StateServer
a user-defined parameter which may be passed to all body delegates
- Type: SystemFunc
a delegate which returns the initial state of the local data for each task
- Type: SystemFunc, , ,
the delegate that is invoked once per iteration
- Type: SystemFunc, ,
the delegate that performs pairwise merging on the local states of each task
- the type of the data elements in source
- the type of the parameter passed to the body delegates.
- the type of the value returned from the localInit delegate that is passed to each body delegate and is subsequently merged via the merge delegate.
the final merged value after all local results and all per-StateServer host results have been merged
Usage NoteIn Visual Basic and C#, you can call this method as an instance method on any object of type IQueryable. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
The body delegate is invoked once for each element in the source enumerable. It is provided with the following parameters: the current element, the user-defined parameter value param, some local loop state that may be shared amongst iteration that execute on the same task.
The localInit delegate is invoked once for each task that participates in the loop's execution (on each host) and returns the initial local state for each of those tasks. These initial states are passed to the first body invocations on each task. Then ever subsequent body invocation returns a possibly modified state value that is passed to the next body invocation.
Local state values from multiple tasks are passed in pairwise fashion to the merge delegate which merges the pair into a single value. Once all local state values from a given host have been merged, they're consolidated from across the distributed store by passing the per-host results in a pairwise fashion to merge delegates hosted on one or more of the StateServer hosts. When all localState values have been merged to a single value, it is returned as the result of the ForEach method.
The source parameter must be a instance initially returned from QueryObjectsT and possibly filtered via one or more Linq where clauses.