Tuesday, December 13, 2016

PetaPoco nuances and triggers

The PetaPoco shortcut ppDB.Insert(obj) or ppDB.Update(obj) cannot be used if the database table has trigger because the following error will be generated:

“The target table '[db table name]' of the DML statement cannot have any enabled triggers if the statement contains an OUTPUT clause without INTO clause.
  

This is because the sql generated by PetaPoco is the following:
INSERT INTO [db table] ([col1], [col2], ... [coln]) OUTPUT INSERTED.[identityColName] VALUES (@0,@1,...@n)

No comments: