Closed geremysremitter closed 1 year ago
Hello @geremysremitter
Are you using a BulkMerge
on a View
? Our library should automatically discover your table has a trigger and adjust the SQL when a Table
is directly used but unfortunately cannot have this logic when a View
is used.
You should be able to fix this issue per table with the options.ForceTriggerResolution = true;
options:
DapperPlusManager.Entity<MyEntityType>().UseBulkOptions(options =>
{
options.ForceTriggerResolution = true;
});
Let me know if that solution worked for you.
Best Regards,
Jon
Hi John,
Nope, we are running the bulk operations on tables (in fact this database has no views at present). The exception sited in the original post went away as soon as I dropped our update triggers on all tables. Bear in mind this is all evaluation stuff so it's no issue dropping these for sake of evaluation however we'd ideally like to enable update triggers in the least.
BTW, this exception only occurs on tables where we've setup as follows
DapperPlusManager.Entity<Widget>().Identity(i => i.WidgetId, true); // produces SqlException at BulkMerge
It seems that
DapperPlusManager.Entity<Widget>().Identity(i => i.WidgetId, false); // no exception at BulkMerge
Works fine
Will report back the results of the options suggestion. Thanks !
Follow-up
The options fix suppressed the SqlException and bulkmerges against tables with update triggers is working. Very nice and thanks for the quick response again.
I will close this out - appreciate it !
Description
Upon performing a BulkMerge against an entity that targets a SQL table with an update trigger, an exception is thrown. This is a SQL Exception which appears to be complaining that the output (presumably of the new ids created during insert / update) is not being put into a variable. This would be a nice-to-have feature, that is, to be able perform bulk operations against tables with triggers.
Tks
Exception
Microsoft.Data.SqlClient.SqlException
Fiddle or Project (Optional)
Any bulkmerge against a table with an UPDATE trigger (we haven't tried with INSERT triggers but assume the same error would occur)
Please advise if you'd like us to send code separately. Thanks
Further technical details