I could investigate ... doesn’t sound trivial, but might be viable.

I suspect it might be tricky when dealing with aliases, but I could give it a 
shot.
From: Fabio Maulo 
Sent: Wednesday, January 26, 2011 3:04 PM
To: [email protected] 
Subject: Re: [nhusers] Re: nHibernate 3 - Problem with DateTime in Query

so far ;) 
perhaps we can use our HQL-fuctions (through Dialect) and get the 
translated-to-SQL chunk to then inject it as SqlFunctionProjection
Viable ?


On Wed, Jan 26, 2011 at 11:43 AM, Richard Brown (gmail) 
<[email protected]> wrote:

  Ah!  I didn't read it closely enough.

  Agreed ... you cannot do that with QueryOver.

  -----Original Message----- From: CSharper
  Sent: Tuesday, January 25, 2011 6:24 PM
  To: nhusers
  Subject: [nhusers] Re: nHibernate 3 - Problem with DateTime in Query 


  Hi,

  no, he wants to use the .NET DateTime.Year property in a QueryOver
  predicate and that's not possible.

  I think it should be something like
    .Where(x => x.Register >= new DateTime(year, 1, 1) && x.Register <
  new DateTime(year + 1, 1, 1)

  Regards.


  On 24 Jan., 10:13, "Richard Brown \(gmail\)" <[email protected]>
  wrote:

    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
    mailto:nhusers%[email protected].
    For more options, visit this group 
athttp://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 
mailto:nhusers%[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 
mailto:nhusers%[email protected].
  For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.





-- 
Fabio Maulo


-- 
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