views:

127

answers:

1

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)

+1  A: 

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 the SubmitChanges method - so it is possible set properties (perhaps based on an interface) for the rows that are being submitted for UPDATE.

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.

Marc Gravell
Oh well, I imagined the answer, but it would have been nice if there had been a way! :)
salgiza