LINQ To SQL: Average Operator

EmpDetails Table:

LinqTable.png


Code:

To return the average value from a Numeric Sequence .


using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Text;
namespace
LINQ
{
class Program
{
static void Main(string[] args)
{
DataClassesDataContext dc = new DataClassesDataContext();
var empQuery = (from emp in dc.EmpDetails
select emp.Allowance).Average();
Console.WriteLine(empQuery.Value);
Console.Read();
}
}
}
Ebook Download
View all
Learn
View all