best way to delete related entity in repository
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?
精彩评论