Compare only date in nHibernate Linq by DateTime

I am trying to compare two dates (DateTime) in nHibernate linq:

query = query.Where(l => (l.datCriacao.Date == dtLote.Date) 

but I get an error:

 NHibernate.QueryException: could not resolve property: datCriacao.Date of: SAGP.Entities.Lote 

Does anyone know how I can solve this? Thanks

+6
date datetime linq compare nhibernate
source share
3 answers

I solved the problem between dates:

 DateTime initialDate, finalDate; initialDate= DateEntity.Date; finalDate= new DateTime(DateEntity.Year, DateEntity.Month, DateEntity.Day, 23, 59, 59); query = query.Where(l => (((l.dateEntity>= initialDate) && (l.dateEntity<= finalDate)) 
+13
source share

This is super old, but I will add a jaspion example like:

 query = query.Where(l => (l.datCriacao >= dtLote.Date && l.datCriacao < dtLote.Date.AddDays(1)) 
+4
source share

You can check a condition like this

var nextDay = DateTime.Today.AddDays (1);

query = query.Where (l => (l.datCriacao> = dtLote & l.datCriacao <nextDay);

here you will receive records of the dtLote date, when we check between dtLote and dtLote + 1 day (00:00:00), we will get today's recording date only that which may ever be time ...

+1
source share

All Articles