开发者

How do I make my repository remove child entities and not just navigation properties from my aggregate root

I'm trying to build a functioning repository using Entity Framework. I feel like I'm missing something really obvious somewhere. Lets say I have IRepository<Person> which has many Address in an ICo开发者_运维知识库llection<Address> Addresses.

When I call Person.Addressess.Remove(sameAddress) I understand this will only remove the navigation (in this case will try to set the PersonID column to null in the database).

The issue is I want to delete it somehow from the aggregate root, so I can just send the Person object to my repository like so personRepository.Update(person) and not have to manually delete the address or create a address repository.

Perhaps I'm searching for the wrong thing but I would have thought this was a common issue, yet I can't seem to find anything on line.


Looks like a future EF release might allow what you're asking for:

http://blogs.msdn.com/b/dsimmons/archive/2010/01/31/deleting-foreign-key-relationships-in-ef4.aspx

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜