I have a lambda statement that has a mapping like this:
public enum Status
{
Completed,
InComplete,
Ok
}
Query:
var courses = query.Select(c => new SomeModel
{
Status = c.someQuery() ? Status.Completed : Status.Ok
});
So I want Status to have multiple if statements and not just a ternary operation. For 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 do I accomplish something like this? I am using Entity framework ORM.
You could nest your ternary operations:
Status = c.someQuery() ? Status.Completed :
c.someOtherQuery() ? Status.InComplete : Status.Ok