Ya is this possible :) ?
views:
92answers:
2can you give me some more details?
Rookian
2010-02-20 16:12:13
Here is good explanation from Ayende: http://ayende.com/Blog/archive/2010/01/16/eagerly-loading-entity-associations-efficiently-with-nhibernate.aspx (HQL). ICriteria example you have from @ewernli.
dario-g
2010-02-20 18:30:57
+1
A:
You can change the fetch mode per query dynamically.
IList cats = sess.CreateCriteria(typeof(Cat))
.Add( Expression.Like("Name", "Fritz%") )
.SetFetchMode("Mate", FetchMode.Eager)
.SetFetchMode("Kittens", FetchMode.Eager)
.List();
See section 12.5 of the documentation.
ewernli
2010-02-20 16:12:09
Is there a BestPractice for hiding the ICriteria API, because I don't want to use this API in the UI Layer? Should I create an overload for my repository.GetAll method or are there some other recommendations?
Rookian
2010-02-21 12:01:54
I'm not sure about what you mean. Have maybe a look at "Wrapping the query APIs" in http://jnb.ociweb.com/jnb/jnbNov2003.html if you are worried about how to offer query facilities in the UI. Otherwise generally speaking, the UI layer depends on the business layer which depends on the data access layer and the nhibernate stuff are usually in the data access layer.
ewernli
2010-02-21 12:55:12
I just override my GetAll method for now. I do not like the ugly strings, I think I write a little helper class for this. Thanks so far.
Rookian
2010-02-22 09:52:31