删除所有对象的最快方法 [英] The fastest way to delete all the objects

查看:133
本文介绍了删除所有对象的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想删除所有对象。例如,我想删除所有类型为"MyEFType"的对象。我想删除所有类型为"YourEFType"的对象其中某些值为"种类"。等于"123"。对数据库执行查询非常简单,但是如何通过ObjectsContext执行此操作?我可以加载所有对象并调用"DeleteObject"对于它们中的每一个,但对于大量对象来说它的工作速度非常慢。我怎样才能更快地完成它?

I want to delete all objects. For example, I want to delete all the objects of type "MyEFType" and I want to delete all the objects of type "YourEFType" where some value "Kind" equals "123". The query to database to do it is very simple, but how can I do it through the ObjectsContext? I can load all the objects and call "DeleteObject" for each of them, but it works very slow for the big amount of objects. How can I do it faster?

推荐答案

您可以简单地创建一个存储过程并使用EF映射它。我怀疑你能找到比这更快的东西。
You could simply create a stored procedure and map it using EF. I doubt you'd be able to find anything faster than that.


这篇关于删除所有对象的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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