开发者

How to return all values of a column as null except one column value in LINQ?

I want to return only one column value and other column values as null from database. how can i do that in LINQ? also have to make values of not nullable fields to null w开发者_如何学编程hile retrieving


C#

var results = from item in db.items
              select (item.col1 == value ? item.col1 : null);

VB.NET

Dim results = From item in db.items
              Select iif(item.col1 == value ? item1.col : Nothing)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜