Comments (3)
I was considering different options to solve the issue and no one is completely satisfactory. This due to combination of different factors:
- Although TransactionScope is handy idea but it gets really tricky http://stackoverflow.com/questions/2884863/under-what-circumstances-is-an-sqlconnection-automatically-enlisted-in-an-ambien
- Of course the issue exists for both AsyncExecute and Execute. The reason I hesitated to implement sync execution as first class concept is because it will require to duplicate all the logic (due to type constrains). I prefer to avoid it if possible. Actually I see sync execution as convenience concept for reasons explained here http://channel9.msdn.com/Series/Three-Essential-Tips-for-Async/Async-Library-Methods-Shouldn-t-Lie and here
#5 (comment) - That said I think real-world application concerns should be address. I see 3 reasonable ways to solve the problem:
- Implement transaction propagation logic similar to TransactionScopeAsyncFlowOption.Enabled on .NET 4. It should not be too hard but might get tricky. Also, it will fix only sync case. For AsyncExecute TransactionScopeAsyncFlowOption.Enabled still has to be used.
- Add constructor overload that accept SqlConnection object. This connection must be open and enlisted into ambient transaction.
- Add to AsyncExecute/Execute last optional parameter of type SqlTransaction.
@danielrbradley What do you think about these options?
from fsharp.data.sqlclient.
I guess the transaction are really an edge issue, so I don't think any of these solutions would actually be necessary.
While the project is still under heavy development I agree that simply providing the synchronous overload is sufficient as a placeholder for convenience, however, when the project heads towards a "1.0" status, as recommended in the channel 9 video, we would not want our synchronous method to lie, and we'd want to look at putting in this work to create a true synchronous method then.
In terms of those three options, if there was a wider requirement for transaction support, I'd personally lean towards the first option as it doesn't pollute the parameters, but if that is too tricky either of those two options would be equally workable.
from fsharp.data.sqlclient.
Transaction support has been added in Nuget release 1.1.28. Constructor now accepts SqlTransaction
as input. This might not be ideal but that's the best we can do without complete duplication of all Async-related code.
use ts = TransactionScope
let conn = SqlConnection
conn.Open()
use tran = conn.BeginTransaction
let cmd = MyQuery(tran)
cmd.Execute(...)
tran.Commit()
ts.Complete()
from fsharp.data.sqlclient.
Related Issues (20)
- Dacpac support info HOT 3
- "F# Formatting" link is broken
- Can't build/run from the commandline, but can from Visual Studio 2019 HOT 2
- Question: Creating a provider without an access to DB HOT 3
- SqlEnumProvider breaks VS 2019 HOT 2
- Not platform detection Fable HOT 1
- Build is broken without full VS installation
- Fixed length binary columns in user defined table types fail when constructed HOT 8
- Cannot use User Defined Table Types with the SqlCommandProvider HOT 5
- .NET 6 support HOT 6
- One line summary of the bug HOT 2
- TVP Column Ordering is incorrect as of version 2.1.0
- Cannot use parameter name more than once in a script HOT 3
- System.Data.SqlClient is not supported on this platform. HOT 5
- Conversion failed when using User Defined Table Types HOT 1
- Any 2023 tricks for running on Windows? HOT 3
- NullReferenceException in SqlConnection.UseLocally HOT 1
- Support for 'Active Directory Interactive' authentication HOT 3
- dotnet SDK projects using FSharp.Core version 7.0.0 breaks at runtime HOT 3
- SQL LIKE operation doesn't recognize variable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsharp.data.sqlclient.