When I'm looking for a record that is mapped to an object model, I have something like this:
var Output = (from x in MyDC.SomeTable
where ....
select new SomeObjectModel()
{
SomeProp = x.SomeColumnField
}.Single();
Now, I want to return on object but only if the object was found I'm doing this:
var Output = (from x in MyDC.SomeTable
where ....
orderby x.SomeTime descending
select s).FirstOrDefault();
This tells me if the object was found and from there, I want to be able to retrieve SomeObjectModel() and fill in its properties but only if there's an element that was found with the .FirstOrDefault() statement and combine all this into one query. I tried adding a Select after .FirstOrDefault() but it doesn't work.
Thanks for your help.
SinglewithFirstOrDefault...