Return selected specified columns

后端 未结 2 1317
半阙折子戏
半阙折子戏 2021-02-20 11:16

I would like to select only few columns from a certain (Blobs) table. I have fields like: Id, RowVersion, Size, Signature, Blob, and I want to select only first four. I do it li

2条回答
  •  佛祖请我去吃肉
    2021-02-20 12:20

    With "select new {" you are creating an anonymous type which cannot be implicitly cast to BlobDetails. Instead, explicitly declare the type you are newing within the select:

    var allBlobs = from b in dc.Blobs
               orderby b.RowVersion descending
               select new BlobDetails {Id = b.Id, .... };
    allBlobs.ToList();
    

提交回复
热议问题