Tags: , , , , | Categories: ASP.Net, C#, LINQ, NHibernate Posted by Scott on 3/26/2012 9:10 AM | Comments (0)

Here are just a few notes on NHibernate LINQ

  • Does not support Intersect or Union - we generally get what we can using NHibernate and then perform these operations on in-memory collections.
  • Does not support IndexOf - however Contains seems to be case insensitive so we just use this instead - we believe Contains becomes a SQL LIKE comparison so this only works if your Contains is executed within SQL - the in-memory operation is case sensitive but in this case IndexOf becomes available.
  • NHibernate 3.1 is now compiled including LINQ - there's no need to reference NHibernate.Linq
Tags: , , | Categories: C#, LINQ, NHibernate Posted by Admin on 8/3/2011 7:49 AM | Comments (0)

We tried to write a filter based on a DateTime? (nullable DateTime) property like

IList<Vacancy> vacancies = manager.Get<Vacancy>(v => v.StartDate.GetValueOrDefault(DateTime.MinValue) < DateTime.Today);

But NHibernate (or possibly NHibernate.Linq) threw a runtime error. It turns out that NHibernate(.Linq) handles all this for us so

IList<Vacancy> vacancies = manager.Get<Vacancy>(v => v.StartDate < DateTime.Today);

Works perfectly!