Replace Linq to Entity value in Projection

entity-frameworklinq

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()
            {
              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?

Best Answer

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"
        };