开发者

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

开发者 https://www.devze.com 2023-02-21 05:36 出处:网络
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 retrievi

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

精彩评论

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