firebird - entity framework triggers don't fire -
can't after insert trigger fire after savechanges() done. using t-sql executestorecommand() doesn't help. triggers fired on server, not entity framework.
what doing: create new row in parent table:
orders order = new orders { guid = guid.newguid().tostring(), orderdate = datetime.now, }; db.addtoorders(order); db.savechanges();
and put data child table trigger must fired after insert:
foreach (sparepart item in somecollection) { orderitems orderitem = new orderitems { order_id = order.order_id, //here order.order_id 0, why? price = item.income_price }; db.orderitems.addobject(orderitem); db.savechanges(); }
the trigger updates parent table:
as begin update orders o set o.sum = o.sum + new.price o.order_id = new.order_id; end
also can't increased order.order_id generated firebird generator, 0 after savechanges() done.
my db schema generated out of firebird database.
if order_id
0 means not configured returned database after insert. check order_id
property configured storegeneratedpattern.identity
.
it reason why trigger doesn't work. fired not existing order_id
(0).
Comments
Post a Comment