Skip to content

.Net: Remove SqlDataReaderDictionary in SQL Server provider - #12241

Merged
Shay Rojansky (roji) merged 3 commits into
microsoft:mainfrom
roji:SimplifySqlServer
May 23, 2025
Merged

Shay Rojansky (roji) merged 3 commits into
microsoft:mainfrom
roji:SimplifySqlServer

Conversation

@roji

@roji Shay Rojansky (roji) commented May 22, 2025 •

Copy link
Copy Markdown
Member

We currently write records to the database by first serializing them to a Dictionary, and then writing that Dictionary out as SqlParameters on the command. Similarly, we read records by allocating and populating a Dictionary, only to then iterate over that Dictionary and populate the .NET instance from it.

This PR does away with the intermediate Dictionary representation. This optimizes serialization by removing the double-copy, reduces allocations, opens the way for boxing-free serialization, and also just simplifies the code (less conversions and stuff to follow).

Part of #11123

@roji
Shay Rojansky (roji) requested a review from a team as a code owner May 22, 2025 16:40
@markwallace-microsoft Mark Wallace (markwallace-microsoft) added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel memory labels May 22, 2025
@github-actions github-actions Bot changed the title Remove SqlDataReaderDictionary in SQL Server provider .Net: Remove SqlDataReaderDictionary in SQL Server provider May 22, 2025

@adamsitnik Adam Sitnik (adamsitnik) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thank you Shay Rojansky (@roji) 👍

@roji
Shay Rojansky (roji) added this pull request to the merge queue May 23, 2025
Merged via the queue into microsoft:main with commit ef8aa2a May 23, 2025
@roji
Shay Rojansky (roji) deleted the SimplifySqlServer branch May 23, 2025 16:02
Eduard van Valkenburg (eavanvalkenburg) pushed a commit that referenced this pull request May 26, 2025
We currently write records to the database by first serializing them to
a Dictionary, and then writing that Dictionary out as SqlParameters on
the command. Similarly, we read records by allocating and populating a
Dictionary, only to then iterate over that Dictionary and populate the
.NET instance from it.

This PR does away with the intermediate Dictionary representation. This
optimizes serialization by removing the double-copy, reduces
allocations, opens the way for boxing-free serialization, and also just
simplifies the code (less conversions and stuff to follow).
jcruzmot-te pushed a commit to thousandeyes/aia-semantic-kernel that referenced this pull request Sep 15, 2025
…t#12241)

We currently write records to the database by first serializing them to
a Dictionary, and then writing that Dictionary out as SqlParameters on
the command. Similarly, we read records by allocating and populating a
Dictionary, only to then iterate over that Dictionary and populate the
.NET instance from it.

This PR does away with the intermediate Dictionary representation. This
optimizes serialization by removing the double-copy, reduces
allocations, opens the way for boxing-free serialization, and also just
simplifies the code (less conversions and stuff to follow).

This branch was previously deployed

1 inactive deployment
integration — 3416c178 Deployed May 23, 2025 by roji
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Issues or pull requests impacting the core kernel memory .NET Issue or Pull requests regarding .NET code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.Net: [MEVD] Stop serializing to intermediate type in relational connectors

4 participants