c# - How to eagerly load several attributes (including parent/grandparent/great grandparent attributes) without having duplicate grandparents on a parent -


i have object want eagerly load, want eagerly load several parent elements, grandparent elements. i've set select so:

var events = (from ed in eventrepo._session.query<eventdata>() idsaslist.contains(ed.id) select ed)                             .fetchmany(ed => ed.parents)                             .thenfetchmany(pa => pa.grandparents)                             .thenfetch(gp => gp.greatgrandparents)                             // other fetches here other attributes                             .tolist(); 

my problem if .fetchmany parents, right number of elements. once add grandparents, way many, , grows more great grandparents.

it's doing kind of cartesian product, had around , saw people use transformers solve this. had @ , tried implement it, adding .transformusing() causes compiler error, since don't seem able call .transformusing() on type of call.

what right way right number of elements such call, without duplicates due computing cartesian product?

here pretty popular post uses futures type of loadign avoid cartesian products. isn't elegant doing in single query gets job done.

fighting cartesian product (x-join) when using nhibernate 3.0.0

one other possible solution define collections sets instead of bags. avoid cartesian product issues. don't solution considering have use nhibernate specific collection type known work.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -