[]
Includes an aggregation subquery into the incremental maintenance mechanism of a view and uniquely identifies it among other subqueries of the same view.
public AggregationView<T, TResult> AttachAggregationView<TResult>(object subqueryId, Func<View<T>, AggregationView<T, TResult>> selector)
Type | Name | Description |
---|---|---|
object | subqueryId | A string uniquely specifying this subquery in the view to which it is attached. Can be any string. The only requirement is that different subqueries attached to the same view, if such exist, must have different subquery ids. |
Func<View<T>, AggregationView<T, TResult>> | selector | A function to obtain the attached aggregation subview from the view to which it is attached. |
Type | Description |
---|---|
AggregationView<T, TResult> | The attached aggregation subview. |
Name | Description |
---|---|
TResult | The type of the elements in the aggregation subview. |
This overload must be used if you have several subviews attached to the same view. The subqueryId' can be any string as long as it is not repeated for two different subviews attached to the same view.
See the other overload for the explanation of the AttachAggregationView method.
Includes an aggregation subquery into the incremental maintenance mechanism of a view.
public AggregationView<T, TResult> AttachAggregationView<TResult>(Func<View<T>, AggregationView<T, TResult>> selector)
Type | Name | Description |
---|---|---|
Func<View<T>, AggregationView<T, TResult>> | selector | A function to obtain the attached aggregation subview from the view to which it is attached. |
Type | Description |
---|---|
AggregationView<T, TResult> | The attached aggregation subview. |
Name | Description |
---|---|
TResult | The type of the elements in the aggregation subview. |
Subquery is a query inside a function that is a part of an outer query. If the outer query is a live view, and its base data changes so it needs to recompute the function, by default it just evaluates the function, which means creating a new view object for the subquery on every such recomputation. To improve performance by avoiding repeated creation of subviews, use the AttachAggregationView method to make the outer view aware of its subview. Then the outer view will cache and reuse subview objects it creates.
If there are more than one subviews attached to a single view, every subview must be supplied with a unique subview id by using the AttachAggregationView overload with subviewId parameter.
var productView =
from p in products
join s in sales on p.ProductID equals s.ProductID into productSales
select new
{
p.Name,
ProductTotal = productSales.AttachAggregationView(v => v.LiveSum(s => s.Quantity))
};