Reputation: 473
I have a department tree hierarchy in firebird I do CRUD on. At least I would like to. Using Linq2Db and the firebird provider I cannot insert into the table without getting the error: violation of FOREIGN KEY constraint
. The problem is I began a transaction. And that's what transactions are for, to (among other things) temporarily disable the FK checks.
I tried both the .Net TransactionScope
and the method LinqToDB.Data.DataConnection.BeginTransactionAsync
. I tried every System.Data.IsolationLevel
. But I keep getting these errors.
How to make Linq2Db transactions work
Upvotes: 0
Views: 43
Reputation: 109263
The behaviour you're expecting only applies to "deferred" constraints, which are checked at commit time. However, all constraints in Firebird are immediate constraints (a.k.a. non-deferrable), which means they are checked immediately when you perform an operation.
In other words, you need to order your operations in such a way that they do not violate the constraints. That is, insert the parent record before a child record.
Upvotes: 0