简体   繁体   English

.NET SQL Server更新触发器

[英].NET SQL Server Update Trigger

I'm updating a SQL Server table (say table1) through .NET Entity Framework. 我正在通过.NET实体框架更新SQL Server表(例如table1)。 table1 has got an update trigger defined which updates data on table2. table1已定义了一个更新触发器,用于更新table2上的数据。 Then upon save changes, an SSRS report gets generated which uses updated data from table2. 然后,在保存更改后,将生成SSRS报告,该报告使用table2中的更新数据。

All this looks good and works fine. 所有这些看起来都不错,并且效果很好。

But, once in a while in deployed application, I see that the generated report gets table2 values those were before trigger execution. 但是,偶尔在已部署的应用程序中,我看到生成的报告获取的是触发执行之前的table2值。

So far it's my understanding that triggers are synchronous, hence couldn't comprehend the reason behind this timing issue. 到目前为止,据我了解,触发器是同步的,因此无法理解此计时问题背后的原因。 Also appreciate if you have any remedy suggestions. 如果您有任何补救建议,也请多谢。

Using .NET Framework 4.6, SQL Server 2014 使用.NET Framework 4.6,SQL Server 2014

I believe the trigger fires off before the update by default. 我相信默认情况下,触发器会在更新之前触发。 to make it fire after you have to define the trigger with the property CREATE TRIGGER AFTER ACTION. 在必须使用属性CREATE TRIGGER AFTER ACTION定义触发器后使其触发。

You could also make the proc that does does the update generate the SSRS report after the update instead of using a trigger. 您也可以使执行更新的proc在更新后生成SSRS报告,而不使用触发器。

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

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