views:

13

answers:

0

Hello,
in one of my project I want to replace linq to sql with linq to nhibernate but I'm facing a strange issue when I use dynamic queries (with the dynamic linq library).

With linq2SQL the following code works but not with linq2nhibernate, at the second apps.Count() nhibernate raises an exception:
A first chance exception of type 'System.NullReferenceException' occurred in NHibernate.DLL

var apps = from x in _service.GetAll()
           select new
           {
               ID = x.Application_ID,
               Name = x.Name
           };
var c1 = apps.Count();

apps = apps.Where("Name.Contains(@0)","work");
var c2 = apps.Count();

Any idea to solve this issue?