Hi Guilherme,

I think you'll need to explicitly join from Evento to Register. Something like this might do it:

session.QueryOver<Evento>()
   .JoinQueryOver(e => e.Register)
       .Where(r => r.Year == year)
       .List();

or

Register registerAlias = null;
session.QueryOver<Evento>()
   .JoinAlias(e => e.Register, () => registerAlias)
   .Where(() => registerAlias.Year == year)
   .List();

http://nhforge.org/doc/nh/en/index.html#queryqueryover-associations

Regards,
   Richard

-----Original Message----- From: Guilherme Cardoso
Sent: Sunday, January 23, 2011 1:38 PM
To: nhusers
Subject: [nhusers] nHibernate 3 - Problem with DateTime in Query

Hi

I'm facing an issue using DateTime property Year. I'm receiving this
message error: NHibernate.QueryException : could not resolve property:
Register.Year of: Estudantino.Domain.Events

In Events class, i'm defining Register like this:

public virtual DateTime Registada { get; set; }

And i'm receiving the error from this query:

using (ISession session = NHibernateHelper.OpenSession())
       {
           return session.QueryOver<Evento>()
               .Where(x => x.Register.Year == year)
               .List();
       }

I only get the error message if i use the property Year of Register.
What should i do to query using the year?

Thanks

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.

--
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to