[]
        
(Showing Draft Content)

C1.LiveLinq.LiveViewExtensions.LiveAggregate

LiveAggregate Method

LiveAggregate<TSource>(View<TSource>, Expression<Func<TSource, TSource, TSource>>, Expression<Func<TSource, TSource, TSource>>, Expression<Func<TSource, TSource, bool>>)

Applies an accumulator function over a view.

Declaration
public static AggregationView<TSource, TSource> LiveAggregate<TSource>(this View<TSource> source, Expression<Func<TSource, TSource, TSource>> funcAdd, Expression<Func<TSource, TSource, TSource>> funcRemove, Expression<Func<TSource, TSource, bool>> funcRemoveDefined)
Parameters
Type Name Description
View<TSource> source

A view to aggregate over.

Expression<Func<TSource, TSource, TSource>> funcAdd

An accumulator function to be invoked on each element that is added to the source view.

Expression<Func<TSource, TSource, TSource>> funcRemove

A function to be applied to the accumulated value and to an element to obtain the changed accumulated value, when an element is removed from the source view.

Expression<Func<TSource, TSource, bool>> funcRemoveDefined

A function used to determine whether funcRemove must be applied when an element is removed from the source view, or the accumulated value is not affected by its removal.

Returns
Type Description
AggregationView<TSource, TSource>

A view representing the final accumulator value.

Type Parameters
Name Description
TSource

The type of the elements of source.

Remarks

It is possible to use standard LINQ query operator Aggregate instead of LiveAggregate. Both are "live" in the sense that they are recomputed automatically when any change occurs in the source. The difference is that Aggregate will every time loop through the entire source collection and aggregate it from scratch, whereas LiveAggregate will use a more performant algorithm, will maintain its value incrementally, processing only those source items that actually changed.

LiveAggregate<TSource, TAccumulate>(View<TSource>, TAccumulate, Expression<Func<TAccumulate, TSource, TAccumulate>>, Expression<Func<TAccumulate, TSource, TAccumulate>>, Expression<Func<TAccumulate, TSource, bool>>)

Applies an accumulator function over a view. The specified seed value is used as the initial accumulator value.

Declaration
public static AggregationView<TSource, TAccumulate> LiveAggregate<TSource, TAccumulate>(this View<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> funcAdd, Expression<Func<TAccumulate, TSource, TAccumulate>> funcRemove, Expression<Func<TAccumulate, TSource, bool>> funcRemoveDefined)
Parameters
Type Name Description
View<TSource> source

A view to aggregate over.

TAccumulate seed

The initial accumulator value.

Expression<Func<TAccumulate, TSource, TAccumulate>> funcAdd

An accumulator function to be invoked on each element that is added to the source view.

Expression<Func<TAccumulate, TSource, TAccumulate>> funcRemove

A function to be applied to the accumulated value and to an element to obtain the changed accumulated value, when an element is removed from the source view.

Expression<Func<TAccumulate, TSource, bool>> funcRemoveDefined

A function used to determine whether funcRemove must be applied when an element is removed from the source view, or the accumulated value is not affected by its removal.

Returns
Type Description
AggregationView<TSource, TAccumulate>

A view representing the final accumulator value.

Type Parameters
Name Description
TSource

The type of the elements of source.

TAccumulate

The type of the accumulator value.

Remarks

It is possible to use standard LINQ query operator Aggregate instead of LiveAggregate. Both are "live" in the sense that they are recomputed automatically when any change occurs in the source. The difference is that Aggregate will every time loop through the entire source collection and aggregate it from scratch, whereas LiveAggregate will use a more performant algorithm, will maintain its value incrementally, processing only those source items that actually changed.

LiveAggregate<TSource, TAccumulate, TResult>(View<TSource>, TAccumulate, Expression<Func<TAccumulate, TSource, TAccumulate>>, Expression<Func<TAccumulate, TSource, TAccumulate>>, Expression<Func<TAccumulate, TSource, bool>>, Expression<Func<TAccumulate, TResult>>)

Applies an accumulator function over a view. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.

Declaration
public static AggregationView<TSource, TResult> LiveAggregate<TSource, TAccumulate, TResult>(this View<TSource> source, TAccumulate seed, Expression<Func<TAccumulate, TSource, TAccumulate>> funcAdd, Expression<Func<TAccumulate, TSource, TAccumulate>> funcRemove, Expression<Func<TAccumulate, TSource, bool>> funcRemoveDefined, Expression<Func<TAccumulate, TResult>> resultSelector)
Parameters
Type Name Description
View<TSource> source

A view to aggregate over.

TAccumulate seed

The initial accumulator value.

Expression<Func<TAccumulate, TSource, TAccumulate>> funcAdd

An accumulator function to be invoked on each element that is added to the source view.

Expression<Func<TAccumulate, TSource, TAccumulate>> funcRemove

A function to be applied to the accumulated value and to an element to obtain the changed accumulated value, when an element is removed from the source view.

Expression<Func<TAccumulate, TSource, bool>> funcRemoveDefined

A function used to determine whether funcRemove must be applied when an element is removed from the source view, or the accumulated value is not affected by its removal.

Expression<Func<TAccumulate, TResult>> resultSelector

A function to transform the final accumulator value into the result value.

Returns
Type Description
AggregationView<TSource, TResult>

A view representing the final accumulator value.

Type Parameters
Name Description
TSource

The type of the elements of source.

TAccumulate

The type of the accumulator value.

TResult

The type of the resulting value.

Remarks

It is possible to use standard LINQ query operator Aggregate instead of LiveAggregate. Both are "live" in the sense that they are recomputed automatically when any change occurs in the source. The difference is that Aggregate will every time loop through the entire source collection and aggregate it from scratch, whereas LiveAggregate will use a more performant algorithm, will maintain its value incrementally, processing only those source items that actually changed.