LINQ 2 Entities , howto check DateTime.HasValue within the linq query

Posted by Snoop Dogg on Stack Overflow See other posts from Stack Overflow or by Snoop Dogg
Published on 2010-05-03T10:45:16Z Indexed on 2010/05/03 10:48 UTC
Read the original article Hit count: 873

Filed under:
|

Hi all ... I have this method that is supposed to get the latest messages posted, from the Table (& EntitySet) called ENTRY

///method gets "days" as parameter, used in new TimeSpan(days,0,0,0);!!

using (Entities db = new Entities())
    {
        var entries = from ent in db.ENTRY
                      where ent.DATECREATE.Value > DateTime.Today.Subtract(new TimeSpan(days, 0, 0, 0))
                      select new ForumEntryGridView()
                      {
                          id = ent.id,
                          baslik = ent.header,
                          tarih = ent.entrydate.Value,
                          membername = ent.Member.ToString()
                      };
        return entries.ToList<ForumEntryGridView>();
    }

Here the DATECREATED is Nullable in the database. I cant place "if"s in this query ... any way to check for that? Thx in advance

© Stack Overflow or respective owner

Related posts about linq-to-entities

Related posts about nullable