开发者

best way to delete related entity in repository

开发者 https://www.devze.com 2023-02-05 21:18 出处:网络
say you have a repository BusinessRepository and you want to have some meth开发者_C百科od that deletes a given BusinessContact, in this scenario Business is the parent and BusinessContact is the child

say you have a repository BusinessRepository and you want to have some meth开发者_C百科od that deletes a given BusinessContact, in this scenario Business is the parent and BusinessContact is the child, one to many, each business can have many contacts, would we have two deletes method in same repository? or put it in the Update method. I am using C# and EF 4. Thankx


Sounds like Business is an aggregate root.

So, i would suggest Adding and deleting contacts through methods on your Business entity which you get using your repository.

Info on Repository Pattern and aggregate roots: What's an Aggregate Root?

0

精彩评论

暂无评论...
验证码 换一张
取 消