Average Operator in Linq to Entity 4 With Examples
Average operator in Linq to Entity Framework 4 with examples
- In this article i will explain the use of average operator in linq to entity framework 4.0
- The Average operator returns the average of the numeric values that exists in the elements of an input sequence.
- One variation of the Average operator enumerates the input source sequence of Numeric type elements by creating an average of the elements.
- The second variation enumerates the source input sequence and determines the average for the member that is returned by a selector for every element in the input source sequence.
- You can use the second syntax for the Average operator to define a query in which the average is just one of the results that needs to be extracted
- The following code examples illustrate the usage of the Average operator.
C#
var expr = (from p in products
select p.Price ).Average()
var expr = (from p in products
select new { p.Price } ).Average(Function(p) p.Price)
Dim expr = (from p in products
select p.Price ).Average()
Dim expr = (from p in products
select new { p.Price } ).Average(Function(p) p.Price)
The above example clearly shows the use of average operator in linq to entityframework 4.0
0 comments:
Post a Comment