Hi Alex,

On Fri, May 20, 2011 at 4:40 AM, H.Alex <[email protected]> wrote:
> I'd use
> QueryOver, for sure it would actually query the db and return just the
> results.

I don't know the QueryOver API (by the way: I couldn't fine any
NHibernate API Reference... could anyone please link me?) and I forgot
to point out that I need to use the LINQ API (but I suppose it's not a
big deal :-)).

> IList<VoicemailMessage> vms =
>    session.QueryOver<VoicemailMessage>()
>        .Where(vm => vm.Sender == sender && vm.LeftAt.CompareTo(from)
>>= 0 && vm.LeftAt.CompareTo(to) <= 0)
>        .List();

Ok. Just a question: why using a DateTime.CompareTo(...) instead of <= or >= ?

> I don't know why you would query the other way. If the point is to
> find all messages by a message sender during a period this should be
> enough.

Agreed. :-)

> This would return all employees that have left messages during the
> period.
>
> IQueryOver<Employee,VoicemailMessage> empQuery =
>    session.QueryOver<Employee>()
>        .JoinQueryOver(emp => emp.SentMessages )
>            .Where(vm => vm.LeftAt.CompareTo(from) >= 0 &&
> vm.LeftAt.CompareTo(to) <= 0);
>
> The messages list would be lazily loaded and the whole list *would* be
> loaded should you access sender.SentMessages.

Ok, now I see what you mean. So you'd add the .SentMessages property
to the IMessageSender interface and leave the VoiceMailMessage.Sender
property, right? I thought you intended to remove the latter. :-)

Thanks again,
Giulio

--

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