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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -