I want to fetch value of field named "Gram" from the last record and put its value into a variable, without using any conditions.
First I tried
int value = int.Parse(Entity.TblGold.LastOrDefault().Gram.ToString());
Second I tried
int value = int.Parse(Entity.TblGold.Select(p => p.Gram).Last().ToString());
I just receive this exception:
LINQ to Entities does not recognize the method 'DataModel.TblGold LastOrDefault[TblGold](System.Linq.IQueryable``1[DataModel.TblGold])' method, and this method cannot be translated into a store expression.