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

后端 未结 2 1248
一生所求
一生所求 2021-01-19 03:50

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 ne

2条回答
  •  遇见更好的自我
    2021-01-19 04:07

    Well... you can exclude entries with DATECREATED equal to null by simply using

    entries = from ent in db.ENTRY 
              where ent.DATECREATED != null
              where ent.DATECREATE.Value > DateTime.Today....
    

    and include them with

      entries = from ent in db.ENTRY 
              where ent.DATECREATED == null ||
                    ent.DATECREATE.Value > DateTime.Today.....
    

    I am not sure though if the second query actually stops checking the where clauses once the first condition is true.

提交回复
热议问题