views:

54

answers:

1

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?

+3  A: 

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"
        };
Marek Karbarz
I suspect Status is an int, but the idea is right on.
tvanfosson
yeah, I originally had code that adds another property to DonationBO, but removed it - the idea is basically the same
Marek Karbarz
I had trid this already but get a compiler error. "semincolon after method or accessor block is not valid" on the semi-colon closing the select statement. So there is something in this usage that Linq is not happy about.
Redeemed1
Ahhh! My problem wa a silly coding error! Dohhh! I had an extra "};" in the code
Redeemed1