我想获得最后一个'Facture',但Max
对我不起作用:
Facture fac = (from c in model.Facture where c.ID = Max(ID) select c).FirstOrDefault();
答案 0 :(得分:4)
只需OrderByDescending
ID,然后选择Facture
最高
Facture fac = model.Facture.OrderByDescending(x => x.ID).FirstOrDefault();
答案 1 :(得分:0)
orderby
来解决问题。Facture fac = (from c in model.Facture orderby c.ID descending select c).FirstOrDefault();