c# - Linq to entities and Hierarchical table -
i have table id , parentid columns nesting level 1(for now).
right load items this:
using (kentities ctx = new kentities()) { ctx.kset.mergeoption = mergeoption.notracking; var items = (from c in ctx.kset c.parentid == 0 select new { title = c.title, id = c.id, subs = ctx.kset.where(o => o.parentid == c.id) }).tolist(); } the other option can choose set self-reference on table, entity expose self-navigation properties , can use load() load children (lazy loading?).
which approach preferred , why?
imho, prefer have done in example. call .tolist() cause know @ moment have data in memory, , don't have worry of problems can have lazy loading.
"it leaks persistent storage access different tiers via lazy loadable associations." taken link
Comments
Post a Comment