var lstCatalog = context.Drinks_Category.Select(x => new { x.Id_category, x.Name_category, x.Parent}).ToList();
私は3列のテーブルを持っています。シーケンス番号の列を追加したいのですが、どうすればいいですか? Id_categoryがKeyです。linQの番号順を選択
ありがとう!
私の新しいコード:
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();
と、このエラー:
System.NotSupportedException:System.Linq.IQueryable 1[<>f__AnonymousType1
4 'エンティティへのLINQのメソッドを認識しない' [可能System.Int32、システム.Drinks_Category、<> f__AnonymousType1を選択します。4](System.Linq.IQueryable
1 [BBModel.Drinks_Category]、System.Linq.Expressions.Expression 1[System.Func
3 [BBModel.Drinks_Category、System.Int32、<> f__AnonymousType1`4 [System.Int32、System.String、System.String、System。 String]]]) 'メソッドを呼び出すと、このメソッドをストア式に変換することはできません。
私は質問を更新しました。私の間違いを訂正してください:( –