开发者

Select only few columns in LINQ query

开发者 https://www.devze.com 2023-01-11 11:28 出处:网络
I have the following query var xyz = from a in prod.Categories where a.CatName.EndsWith(\"A\") select a;

I have the following query

 var xyz = from a in prod.Categories
                           where a.CatName.EndsWith("A")
                           select a;

However all the columns are returned in this case. How do i rewrite query so that only few column开发者_StackOverflows are returned like a.CatName, a.CatID, a.CatQty and so on.


var xyz = from a in prod.Categories
                           where a.CatName.EndsWith("A")
                           select new { CatName=a.CatName, CatID=a.CatID, CatQty = a.CatQty};


 var xyz = from a in prod.Categories
                           where a.CatName.EndsWith("A")
                           select new { a.CatID,a.CatQty } ;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号