IF statement inside a LINQ SELECT

linq-to-sql

Solution

Status = e.col1.HasValue ? "This Value" : (e.col2.HasValue ? "Other Value" : null)

Problem

I'm trying to produce an IF conditional statement inside of a "select new" that checks the values of two fields in order to fill a property. ``` from e in Employees where e.EmployeeID == id select new { EmployeeID = e.EmployeeID, EmployeeName = e.FirstName + " " + e.LastName, Status = (if e.col1.HasValue then "This Value" else if e.col2.HasValue then "Other Value") } ``` The columns are nullable and therefore the column types are DateTime? data types. Only one or the other column will have a datetime value, not both. How do I go about doing this???

Original source