var lstCatalog = context.Drinks_Category.Select(x => new { x.Id_category, x.Name_category, x.Parent}).ToList();
I have a table of 3 columns. I want to add a sequence number column, so how do I do it? Id_category is Key.
Thanks you!
My new code:
var lstCatalog = context.Drinks_Category.Select((x, i) => new { Index = i, x.Id_category, x.Name_category, x.Parent }).OrderByDescending(x=>x.Id_category).ToList();
and this error:
System.NotSupportedException: 'LINQ to Entities does not recognize the method 'System.Linq.IQueryable1[<>f__AnonymousType1
4[System.Int32,System.String,System.String,System.String]] Select[Drinks_Category,<>f__AnonymousType14](System.Linq.IQueryable
1[BBModel.Drinks_Category], System.Linq.Expressions.Expression1[System.Func
3[BBModel.Drinks_Category,System.Int32,<>f__AnonymousType1`4[System.Int32,System.String,System.String,System.String]]])' method, and this method cannot be translated into a store expression.'