You're welcome :)

I don't know about the FindAll API as I don't use it. I'd use
QueryOver, for sure it would actually query the db and return just the
results.

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

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.

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.

I actually missed the Ids being of different type. Yeah, I tried and
that won't work with <any>. I don't have any ideas.

On May 19, 10:03 am, Giulio Petrucci <[email protected]>
wrote:
> Hi Alex,
>
> On Wed, May 18, 2011 at 9:04 PM, H.Alex <[email protected]> wrote:
> > or, even better, using this for IMessageSender :)
>
> >    public interface IMessageSender
> >    {
> >        IList<VoicemailMessage> SentMessages { get; }
> >    }
>
> that's a nice paradigm shift. :-)
> Anyway it's not so straightforward. Let me explain what I mean
> shifting a bit the focus of the thread.
> On the long term, each Employee/Friend will leave *a lot* of voice
> mail messages in the system. Let's suppose I have to check all the
> messages that the employee Giulio Petrucci left in the system from a
> certain date to another date (the VoiceMailMessage entity has a
> property LeftAt od type DateTime). So, having:
>
> DateTime from = ...;
> DateTime to = ...;
> EmployeeId myId = ...;
> ISession s = ...;
>
> in the first way, I'd have:
>
> var me = s.Get<Employee>(myId);
> var messages = s.Query<VoiceMailMessage>().Where(m => m.Sender ==
> me).Where(m => m.LeftAt >= from && m.LeftAt <= to).ToList();
> [code written on-the-fly :-P don't know it if compile/works at all]
>
> in the other way, I'd have:
>
> var messages = s.Get<Employee>(myId).FindAll(m => m.LeftAt >= from &&
> m.LeftAt <= to).ToList();
> [code written on-the-fly :-P don't know it if compile/works at all]
>
> My (new) question is: the IMessageSender.MessagesSent list is actually
> fetched when queried by the .FindAll()? Because fetching all the
> messages could be a bit "heavy". :-)
>
> Thanks in advance,
> 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