在LINQ禁用触发器SQL

在LINQ禁用触发器SQL

本文介绍了在LINQ禁用触发器SQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经创建了与它每次有一个UPDATE / INSERT更新一个ModifiedDate领域的触发器的表。对于我们的应用程序特定的交易,不过,我们想暂时禁用该触发器。

We have created a table with a trigger that updates a ModifiedDate field in it each time there is an UPDATE/INSERT. For a particular transaction in our app, though, we would like to temporally disable this trigger.

有没有可能直接从LINQ做到这一点?
(直接,而不是调用存储过程)

Would it be possible to do this directly from LINQ?(Directly, not calling a stored procedure)

推荐答案

不使用生成的代码。你可以挂接到一个存储过程,但可能涉及额外的工作。

Not using the generated code. You could hook into a stored procedure, but that may involve extra work.

有关最近更新的数据,有可能钩到所以它是行可能的属性集(可能是基于接口的) - 这是的SubmitChanges 方法的过程中获得的DataContext 的变化集正在提交更新

For "last updated" data, it is possible to hook into the DataContext's change-set that is obtained during the SubmitChanges method - so it is possible set properties (perhaps based on an interface) for the rows that are being submitted for UPDATE.

我有一个类似的问题,在我的审计触发不同的行为在此基础上列(通过更新(的ColumnName)触发器)的更新语句的一部分,所以在类似的问题我该数据上下文劈死。这可能具有的部分的交叉

I have a similar issue, where my audit triggers behave differently based on which columns are part of the UPDATE statement (via UPDATE(ColumnName) in the trigger), so in a similar question I needed to hack the data-context to always consider a specific column dirty. That may have some cross-over.

但是,没有:我不认为你可以完全禁用触发器

But no: I don't think you can disable the triggers completely.

这篇关于在LINQ禁用触发器SQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 22:23