I assume some have already gotten LinqNH going with FNH.  Could someone
enlighten me?  It was really simple to just add the nh.linq.dll and then I
could run a linq query like this:

var list = from c in session.Linq<User>()
                where c.FirstName.StartsWith("J")
                select c;

But is that the recommended way?  The User class has IList<TimeEntry>
TimeEntries mapped, and that works.  Is it legitmate to use linq on it?  I
wrote a test and it worked.  I'm new to linq and FNH and NHib; I've used
Castle AR but never NH directly before.

My initial test looks like this (no actual TimeEntry records exist in the
integration test db)

[Fact]
public void CanQueryTimeEntriesWithLinq()
{
   var session = base.CreateSessionFactory().OpenSession();
   var userList = session.CreateCriteria(typeof(User)).List<User>();
   var user = userList[0];

   var list = from c in user.TimeEntries
      where c.EntryDate > DateTime.UtcNow.AddMonths(-1)
      select c;

   Assert.NotNull(list);
}

Thanks,
-j


Josh C.
480-270-4578 | josh [at] computeristsolutions [dot] com |
http://computeristsolutions.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" 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/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to