Skip to content

Add Thread-Safe SqlGenerator implementation#309

Open
xamele0n wants to merge 5 commits into
tmsmith:masterfrom
xamele0n:hotfix/concurrency
Open

Add Thread-Safe SqlGenerator implementation#309
xamele0n wants to merge 5 commits into
tmsmith:masterfrom
xamele0n:hotfix/concurrency

Conversation

@xamele0n

@xamele0n xamele0n commented Oct 6, 2022

Copy link
Copy Markdown

Default SqlGenerator has properties
IList<IColumn> AllColumns { get; } IList<Table> MappedTables { get; }
that filled and modified in different methods. This data shared across methods inside SqlGenerator in non-threadsafe manner and it can be changed by differrent (parallel) thread.
Whole sql statement must be composed by it`s own SqlGenerator

@xamele0n

xamele0n commented Oct 6, 2022

Copy link
Copy Markdown
Author

Fix #303 #298 #274
Requesting @valfrid-ly for review

@skovsende

Copy link
Copy Markdown

@xamele0n Do you happen to have created a nuget package with this fix that you can share? :)

@skovsende

Copy link
Copy Markdown

Nm. I made one myself: https://www.nuget.org/packages/Swush.DapperExtensions/1.7.1-hotfix-concurrency

It's basically just the code from this PR. Do note that it only supports .net 6 and 7.

@skovsende

Copy link
Copy Markdown

Anyway - deployed the fix on production - and got the same error as described in #298 almost immediately. So this does not fix #298 - unfortunately!

@xamele0n

Copy link
Copy Markdown
Author

@skovsende - well.. i did`t noticed that fields are used outside forming sql. I did rewrite implementation according your case. You can try this.

@skovsende

skovsende commented Apr 14, 2023

Copy link
Copy Markdown

Great job! It fixes the code I posted in #298. I decided to get rid on our dependency on DapperExtensions as we weren't really using it for much, but for everyone else I have uploaded a package based on this PR here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants