Thursday, April 21, 2011

Compare only Date in nhibernate linq on a DateTime value

Hello, I trying to compare two dates (DateTime) in nhibernate linq: query = query.Where(l => (l.datCriacao.Date == dtLote.Date)

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

anyone knows how I can solve this?

tks

From stackoverflow
  • You cant do it via current version of linq to hibernate. it is made based on Criteria API.

    jaspion : and how I can do it? only with hql?
    Sly : Yes, hql probably
    Paco : 2 current versions exist
    Sly : I mean current released versions...
  • I solved the problem doing a between with the 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))
    

0 comments:

Post a Comment