c# - Big collections in DDD using Entity Framework -
i try use ddd describe domain model , code first approach on mapping database tables entity framework (using fluent api). example have 2 entities: clubs , users. club has many users. , need add new user club.
class user { public string name { get; set; } public club club { get; set; } } class club { public string clubname { get; set; } public icollection<user> members { get; set; } public void addnewmember(user user) { //..some logic , checks members.add(user); } }
- so, should load users collection in club add new , save? or it's excessively?
- what best way modeling entities big collections? should load them? or move separate object?
should load users collection in club add new , save?
no, can add new user
club.members
, ef save new user. it's not necessary load users first.
what best way modeling entities big collections
that doesn't depend on potential size of collections on how plan access them. if there club
s thousands of users
there's no objection whatsoever if you'd want query small subset of users query this:
from c in clubs u in c.users c.type = "golf" && u.membership = "gold" select u
i encourage using navigation properties. ef entity model accessing database in first place. ddd concerns secondary.
of course should prevent queries in users of club loaded, unless need them.
Comments
Post a Comment