Jayanth Reddy

Jayanth Reddy

  • 1.7k
  • 98
  • 1.1k

Retreiving Data

Aug 13 2019 2:32 AM
I am trying to retreive the Max value of Id from the sql server using "Linq to sql" to display in the form, but getting 0 as the value.Instead of Max, if i use a Count() it is giving the exact count value.Can anyone help me how to get the max value of a column using linq to sql query.
 
CompanyDataContext dc = new CompanyDataContext();
Employee obj = new Employee();
var c = ((from Employee in dc.Employees select obj.id).Max());
label6.Text=(c+1).ToString();
 

Answers (2)