开发者

How in Linq to entity replace true or false with On or Off?

I need to bind grid with linq to entity(asp C#), when Im binding I need to replace true or false with On or Off. how I can accomplish it?

ex.

var t = from k in entity.table se开发者_运维百科lect k.IsActive;

so in result if

IsActive == true I need to return On

IsActive == false I need to return Off


var t = from k in entity.table select k.IsActive ? "On" : "Off";


Have you tried this?

var t = from k in entity.table select (k.IsActive ? On : Off); 


try this

var t = from k in entity.table select k.IsActive.GetValueOrDefault() ? "On" : "Off";
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜