Hi,
I have a context with some Employee objects that have a property of ClockNo which is an int. I would like to use a lambda expression to
assign either the clockno value to the IsInSQL variable or if there is no employee that has a ClockNo that matches xClock than I want var to
IsInSQL to equal something letting me know there was no match (could be 0 or "NO"..... I figured it should be an int since clockno is of type int)
This code gives me a null exception error if no employee exists with that clockno
var IsInSQL = context.Employees.Where(c=>c.ClockNo == xClock).FirstOrDefault().ClockNo
I also tried using DefaultIfEmpty() with First(), but I still get an error, I think, because there is no employee with xClock as opposed to an empty Clock value.
Any suggestions ?
...
Go to the complete details ...