c# - LINQ to create a calculated value based on the value of two other columns -
simplified scenario:
i want create calculated string property based on value of 2 properties, field1 , field2. when field1 has value, field2 null, , viceversa. can't both null.
let's call calculated value "cv". rule is: if field1 null, cv = field2, , if field2 null, cv = field1.
how can achieve using linq entities?
thanks.
will work you?
context.people.select(p => new {cv = p.displayname ?? p.realname});
Comments
Post a Comment