c# - If statement and assignments in lambda expressions -


i have lambda statement has mapping this:

public enum status {     completed,     incomplete,     ok } 

query:

var courses = query.select(c => new somemodel       {           status = c.somequery() ? status.completed : status.ok       }); 

so want status have multiple if statements , not ternary operation. eg.

var courses = query.select(c => new somemodel       {           status = if(c.somequery())                    {                         return status.completed;                    }                    else if(c.someotherquery())                    {                        return status.incomplete;                    }                    else if(c.someotherquery1())                    {                        return status.ok;                    }       }); 

so how accomplish this? using entity framework orm.

you nest ternary operations:

status = c.somequery() ? status.completed :      c.someotherquery() ? status.incomplete : status.ok  

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -