简体   繁体   English

ASP.NET实体Linq

[英]ASP.NET Entity Linq

Searching here I see 在这里搜索,我看到了

db.ProRel.RemoveRange(db.ProRel.Where(c => c.ProjectId == Project_id));

can be used to remove a set of records. 可用于删除一组记录。 However, if you want to remove a large number of records, like 1000s or more, you don't want to bring them into memory. 但是,如果要删除大量记录(例如1000条或更多),则不希望将它们带入内存。 Can Linq do it, or do you do you need to drop into SQL? Linq可以做到吗,还是您需要使用SQL?

There is a 3rd party library called EntityFramework.Extended that lets you do a batch to delete a set of specific rows. 有一个名为EntityFramework.Extended的第三方库,可让您进行批处理以删除一组特定的行。 In your case it would be: 您的情况是:

db.ProRel.Where(c => c.ProjectId == Project_id).Delete();
db.SaveChanges();

Just install this nuget package and execute the code I show above. 只需安装此nuget软件包并执行上面显示的代码即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM