Skip to content

.Net: Remove SqlDataReaderDictionary in SQL Server provider#12241

Merged
roji merged 3 commits intomicrosoft:mainfrom
roji:SimplifySqlServer
May 23, 2025
Merged

.Net: Remove SqlDataReaderDictionary in SQL Server provider#12241
roji merged 3 commits intomicrosoft:mainfrom
roji:SimplifySqlServer

Conversation

@roji
Copy link
Member

@roji roji commented May 22, 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).

Part of #11123

@roji roji requested a review from a team as a code owner May 22, 2025 16:40
@markwallace-microsoft 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
@roji roji temporarily deployed to integration May 22, 2025 16:40 — with GitHub Actions Inactive
@github-actions github-actions bot changed the title Remove SqlDataReaderDictionary in SQL Server provider .Net: Remove SqlDataReaderDictionary in SQL Server provider May 22, 2025
@roji roji force-pushed the SimplifySqlServer branch from a7517a5 to 57f9c48 Compare May 22, 2025 16:54
@roji roji temporarily deployed to integration May 22, 2025 16:54 — with GitHub Actions Inactive
@roji roji enabled auto-merge May 22, 2025 17:12
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

Very nice! Thank you @roji 👍

@roji roji temporarily deployed to integration May 23, 2025 13:45 — with GitHub Actions Inactive
@roji roji force-pushed the SimplifySqlServer branch from 1c521b2 to 3416c17 Compare May 23, 2025 15:30
@roji roji temporarily deployed to integration May 23, 2025 15:31 — with GitHub Actions Inactive
@roji 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
19 checks passed
@roji roji deleted the SimplifySqlServer branch May 23, 2025 16:02
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).
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