LINQ To SQL: Min operator

EmpDetails Table:

LinqTable.png


Code:

To find the Minimum Value in 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 minSalary = (from emp in dc.EmpDetails
                 select emp.Salary).Min();
Console.WriteLine(minSalary);
Console.Read();
}
}
}


Output:

50000
Next Recommended Reading LINQ To SQL: Sum operator