Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAllow passing in database transaction to query execution #130
Conversation
nauhalf
commented
Oct 5, 2018
There's still no update in SqlKata.Execution, i want to use Transaction |
Any update on this? Really need to use transactions with the queries, other than that, this package is perfect for my project. |
nauhalf
commented
Oct 6, 2018
@RichardAnderson for now I got transaction by using TransactionScope. it's work with MySQL. |
@nauhalf Any codesnippits on how you managed to do that, I'm working with MSSQL, but I might be able to adjust my code to accommodate it. |
nauhalf
commented
Oct 6, 2018
like this |
Thanks @nauhalf This works perfectly for insert / update operations. However it unfortunately does not reverse the .Statement() commands I run through QueryFactory.StatementAsync() |
ghost
commented
Dec 14, 2018
+1 Need this for my application. |
d792b01
to
925c845
angelul
commented
Feb 7, 2019
@ceastwood any news? |
angelul
commented
Feb 7, 2019
@ahmadmuzavi Any updates? |
@angelul I haven't been committing to the SqlKata.Execution project but will take a deeper look this PR afternoon. At first glance I don't think the PR as-is is complete for merging, but hold my reservation. |
As an update, I started to take a look and I think we might want to add the support to just a few more methods. I will circle back after work and try to update. |
@angelul actually I am looking for a better way to handle transactions, I don't find that passing the transaction in all methods is the right way. |
Hi - any update on this at all? This is the ONLY blocker for many of my projects at present, where it's not possible to reverse all queries and statements. |
@RichardAnderson why you can't use the solution suggested by @nauhalf ? |
myargeau
commented
Sep 3, 2019
I tried using @nauhalf's solution to get the id of the inserted (so that @@IDENTITY is executed in the same scope), but it does not work either. |
@myargeau do you mind sharing code that reproduce the issue?, since I am using it with no problem with SqlServer, |
myargeau
commented
Sep 4, 2019
•
This gives an error saying 'The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.', Like each statement is in its own context.
This executes, but returns null (maybe because of our Trigger 'INSTEAD OF INSERT')
This throws an exception at the first Query "ExecuteNonQuery requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized." The Connection.Open() was added because the BeginTransaction() was throwing an exception saying that the connection was closed.
This works, but since I have 10 fields to insert, I lose the advantage to use SqlKata because I have to write my whole query manually.
|
cunnpole
commented
Oct 8, 2019
The ability to pass in an existing transaction is vital to me as I already have a large codebase that makes heavy use of transactions. There is currently no way for me integrate Kata without using Mitch528's changes. |
f9a6417
to
a30bb49
kidmar
commented
Jan 31, 2020
This commit would get the work done and requires the caller to only pass the transaction in the constructor of the QueryFactory. |
Mitch528 commentedAug 23, 2018
Resolves #113