Last
or LastOrDefault
are not supported in LINQ to Entities. You can either iterate your query using ToList
or ToArray
and then apply Last
or you can order by descending and then use the First
like:
int value = int.Parse(Entity.TblGold
.OrderByDescending(p => p.Gram)
.Select(r => r.Gram)
.First().ToString());