删除实体及其导航属性 [英] Deleting Entities and its Navigation Properties

查看:62
本文介绍了删除实体及其导航属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ICollection< Orders> 中有一个客户对象,该对象具有50000个订单。
假定客户位于本地缓存中,而不是订单。如何删除Cutomer及其所有相关订单,而又不将所有Customer订单加载到缓存中并用 setDeleted()进行标记?
此处的最佳做法是什么。我认为扩展 public SaveResult SaveChanges(JObject saveBundle)方法是最好的方法。客户端上的其他任何可能性,例如标志 delete_all_navigation_too()

I have something like a Customer object with up to 50000 order in an ICollection<Orders>. Assume the Custome being in the local cache, the orders not. How can i delete the Cutomer and all of its related orders without loading all of the Customer orders into the cache and marking them with setDeleted()? What is the best practice here. I assume extending the public SaveResult SaveChanges(JObject saveBundle) method is the best way. Any other possibilities here on the client side like a flag delete_all_navigation_too()?

谢谢

推荐答案

我能想到的最简单的方法是在数据库上创建级联删除约束,以便在删除客户时删除其所有订单。也一样然后,只需在客户端上删除客户并致电 SaveChanges。此外,由于Breeze尚不支持客户端的级联删除(我们正在考虑这样做),因此您需要遍历已加载的所有客户端订单并分离它们。

Simplest approach that I can come up with is to create a cascade delete constraint on the database so that when a customer is deleted all of its orders get deleted as well. Then simply delete the customer on the client and call 'SaveChanges'. In addition, since Breeze does not yet support client side 'cascaded' deletes ( we are considering this one), you will need to iterate over any client side orders that are already loaded and 'detach' them.

这篇关于删除实体及其导航属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆