Wednesday, March 13, 2013

How found max id use LINQ?

If you want max Id from your table using LINQ then you can use bellow code.

int maxIdProd = context.Product.OrderBy(o => o.Id).Last();
// OR
var max = context.Product.Select(x=>x.ProductID).Max(); 


Enjoy!!

No comments:

Post a Comment