What's FirstOrDefault for DateTime in Linq?
Posted
by Keltex
on Stack Overflow
See other posts from Stack Overflow
or by Keltex
Published on 2010-04-23T17:33:57Z
Indexed on
2010/04/23
18:03 UTC
Read the original article
Hit count: 331
If I have a query that returns a DateTime, what's the value of FirstOrDefault? Is there a generic way to get the default value of a C# scalar? Example:
var list = (from item in db.Items
where item.ID==1234
select item.StartDate).FirstOrDefault();
Edit: Assume that the column StartDate can't be null.
© Stack Overflow or respective owner