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);     } } 
  1. so, should load users collection in club add new , save? or it's excessively?
  2. 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 clubs 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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -