i want to create a method that can be used with lambda in that way:
return Method<MyClass>(x => x.PropName1, x.PropName2,...);
inside it i have to use tha propName to eager load those reference field via nhibernate:
return session.Query<MyClass>()
.Fetch(c => c.PropName1)
.Fetch(c => c.PropName2).ToList();
i look into linq source code to find some similar and went here:
public static void ListEager<TEntity>(IEnumerable<Func<TEntity, TKey>> fields)
but it's simply not correct.
how can it be done?
i switch to queryover to get more power :D
in this way i can manage reference or hasmany without problem
i left @mww as accepted answer because the main idea is his
You can do like this, implement
IGeneric
interface andGeneric
class, with generic methodGetList
, i use this generic method and working very well.To use it you need create repository class for any entity, here is example with my
ProductRepository
class