First of all, apologize to Ayende, I hope you can find the real reason. 2009/8/15 Jeffrey Zhao <[email protected]>
> > http://ayende.com/Blog/archive/2009/07/26/nhibernate-linq-1.0-released.aspx > > Well, NHibernate Linq is officially released and in ayende's article he > said "NHibernate’s Linq support has been tested (in production!) for the > last couple of years, and most people find it more than sufficient for their > needs". So I don't think NH.Linq should be broken in this kind of simple > piece of scenario. > > Maybe I did something wrong with NH.Linq for the lack of docs. > > > Blog: http://www.cnblogs.com/JeffreyZhao/ > Twitter: http://twitter.com/jeffz_cn > > *From:* 江名峰 <[email protected]> > *Sent:* Saturday, August 15, 2009 1:21 PM > *To:* [email protected] > *Subject:* [nhusers] Re: Use NHibernate.Linq to get single entity with > eager load > > 老赵, I think the current version of NHibernate.Linq not use it in a > production environment, if the two ways for writing the generated SQL is the > same, and has been the object is different, then the problem is the Linq > > 2009/8/15 Jeffrey Zhao <[email protected]> > >> Hello, I met a problem when use NHibernate.Linq to get single entity >> with eager load. For example I've a the models like: >> >> public class Product { ... } >> public class Product >> { >> public virtual int ProductID { get; set; } >> public virtual string Name { get; set; } >> public virtual ISet<Property> Properties { get; set; } // lazy load by >> default. >> } >> >> >> That's simple. When I try to load the single Product with id equals 1 >> eagerly: >> >> var product = session >> .CreateCriteria(typeof(Product)) >> .Add(Expression.IdEq(1)) >> .SetFetchMode("Properties", FetchMode.Eager) >> .UniqueResult<Product>(); >> >> >> This works pretty fine (a Product instance contains 2 Property instances), >> but when I want to use NHibernate.Linq to do the same thing: >> >> var product = session.Linq<Product>().Expand("Properties").Single(p => >> p.ProductID == 1); >> >> >> It throws an exception with message "Sequence contains more than one >> element". The problem still exists if I use ".Where(p => p.ProductID = >> 1).Single()", then I simply tried to use "First" instead of "Single". No >> exception throwed but I got a Product instance contains _only 1_ Property >> instance - it should be 2 actually. >> >> But the interesting thing is, with the help of SQL Profiler, I found that >> the SQL queries generated by Criteria API and LINQ are just the same - seems >> like a bug in NHibernate.Linq? >> >> >> >> Blog: http://www.cnblogs.com/JeffreyZhao/ >> Twitter: http://twitter.com/jeffz_cn >> >> >> > > > -- > 江名峰 > msn:[email protected] > > > -- 江名峰 msn:[email protected] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
