开发者

Replace Linq to Entity value in Projection

开发者 https://www.devze.com 2022-12-12 16:25 出处:网络
I want to relace a value retrieved from a L2E projection to an expanded string. The table contains a column called Status which can have a value \"0\" or \"1\" and in my L2E I have

I want to relace a value retrieved from a L2E projection to an expanded string.

The table contains a column called Status which can have a value "0" or "1" and in my L2E I have

var trans = from t in db.Donation
            select new DonationBO()
            {
        开发者_如何学Python      Status = t.Status
            };

What I want is to return either of the strings "Pending" or "Committed" instead of "0" or "1".

How can I do this here?


If Status is a string you could simply do:

var trans = from t in db.Donation
        select new DonationBO()
        {
          Status = t.Status == "0" ? "Pending" : "Committed"
        };
0

精彩评论

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