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.
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.
For “last updated” data, it is possible to hook into the
DataContext‘s change-set that is obtained during theSubmitChangesmethod – so it is possible set properties (perhaps based on an interface) for the rows that are being submitted forUPDATE.I have a similar issue, where my audit triggers behave differently based on which columns are part of the
UPDATEstatement (viaUPDATE(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.