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 Offvar 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";
精彩评论