c# - 如何删除对象而不在 EF 中检索它

标签 c# .net entity-framework visual-studio-2012

我们有一个表,其中有几个 nText 列,因此希望删除行而不检索它(如果可能的话)

另一个问题是我们不知道 IDentity 值,但知道一些其他唯一标识该行的值,因此下面的示例将无法正常工作

http://blogs.msdn.com/b/alexj/archive/2009/03/27/tip-9-deleting-an-object-without-retrieving-it.aspx

希望 EF5 中有一些更新的东西来解决这个问题而不求助于存储过程?

最佳答案

使用ExecuteStoreCommand

例如:

databaseContext.ExecuteStoreCommand("DELETE FROM [table] where ... ");

关于c# - 如何删除对象而不在 EF 中检索它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16728481/

相关文章:

c# - 在窗口上绘制位图时不需要的抗锯齿

C#:分页,Math.Ceiling

c# - Entity Framework ——CreateQuery VS ExecuteFunction VS ExecuteStoreQuery VS ExecuteStoreCommand

c# - 如何通过长除法运算得到小数

c# - 无需端口转发的 UDP/TCP 发送和接收

c# - 方法 - 32 位与 try-catch 以及 iSeries ODBC 驱动程序

c# - 非托管代码中的 ASP.NET Core 1.1 和 EF 6 异常

c# - EF5 收到此错误消息 : Model compatibility cannot be checked because the database does not contain model metadata

.net - .NET中的引用如何定位?

entity-framework - Entity Framework 显式加载多级