Net4x.DapperLibrary.MergeUtility
1.9.9.6
dotnet add package Net4x.DapperLibrary.MergeUtility --version 1.9.9.6
NuGet\Install-Package Net4x.DapperLibrary.MergeUtility -Version 1.9.9.6
<PackageReference Include="Net4x.DapperLibrary.MergeUtility" Version="1.9.9.6" />
<PackageVersion Include="Net4x.DapperLibrary.MergeUtility" Version="1.9.9.6" />
<PackageReference Include="Net4x.DapperLibrary.MergeUtility" />
paket add Net4x.DapperLibrary.MergeUtility --version 1.9.9.6
#r "nuget: Net4x.DapperLibrary.MergeUtility, 1.9.9.6"
#:package Net4x.DapperLibrary.MergeUtility@1.9.9.6
#addin nuget:?package=Net4x.DapperLibrary.MergeUtility&version=1.9.9.6
#tool nuget:?package=Net4x.DapperLibrary.MergeUtility&version=1.9.9.6
DapperLibrary.MergeUtility
Utilities to merge in-memory data (primarily DataTable) into a relational database table via the DapperLibrary IDapperContext abstractions. The library provides a configurable merge engine that generates and executes insert/update/delete statements according to the provided source data and database metadata.
Overview
- Purpose: synchronize rows from an in-memory source (e.g.
DataTable,DbDataReaderor key/value pairs) into a target database table while handling inserts, updates and optional deletes of non-existing rows. - The engine is designed to be provider-agnostic: it maps CLR types to database types, prepares parameters, formats SQL and executes batched operations using the host
IDapperContext.
Main components
IMergeHelper� simple public interface exposingMerge()andMergeDataTable(params string[]? primaryKeys).MergeHelper(extensions) � extension methods onIDapperContextthat:MergeDataTable(DataTable? dataTable, params string[] primaryKeys)� convenience wrapper to run a merge for aDataTable.MergeDataTable(DataTable? dataTable, bool deleteNonExisting, params string[] primaryKeys)� same but optionally delete rows in the DB that are not present in the source.- Factory methods to create
IMergeHelperinstances fromDataTable,DbDataReaderor arrays of key/value pairs.
MergeHelperInternaland supporting internals � the core implementation (split across files) that:- Computes table metadata (
TableMetaData) and column mappings. - Builds parameterized SQL statements for
INSERT,UPDATEandDELETEoperations usingSqlFormatterandRowHelperBase/RowInsertHelper/RowUpdateHelper/RowDeleteHelper. - Manages value extraction/wrapping for
DataTableandDbDataReadersources via data wrappers. - Provides hooks for dumping generated SQL (
DumperInternal) and for processing rows before save (ProcessRowBeforeSaveEventArgs).
- Computes table metadata (
Mapping and helpers
- Type mapping (
DbTypeMapper,ToDbTypeHelper,DataBaseConstants) ensures parameters use appropriateDbTypevalues for the provider. ParameterReplacerHelperandParameterReplaceExtensionassist with named/positional parameter transformation when generating provider-specific SQL.MergeHelperCreatoris used to create the internal helper instances (internal factory/DI style).
- Type mapping (
Usage examples
Merge a DataTable into the database:
// 'context' is an IDapperContext instance
int affected = context.MergeDataTable(myDataTable, "Id");
// With delete of non-existing rows
int affected2 = context.MergeDataTable(myDataTable, true, "Id");
Create and use a merge helper directly:
var helper = context.CreateMergeHelper(myDataTable);
helper.Merge();
Create a helper from a DbDataReader or from in-memory key/value pairs:
var readerHelper = context.CreateMergeHelper(myDbDataReader, "MyTable");
var kvpHelper = context.CreateMergeHelper(keyValuePairsArray, "MyTable");
Behavior & customization
- The extension
MergeDataTablesets theDataTable.PrimaryKeybased on the providedprimaryKeysand ensures the target table exists by callingCreateDataTableIfNotExistson theIDapperContextprior to merging. MergeHelperInternalexposes options and events (internal) to tweak behaviors such as SQL dumping, row pre-processing and delete handling.- The engine tries to be efficient and safe by using parameterized statements and provider-aware
DbTypesettings.
Dependencies and compatibility
- Depends on
DapperLibrary.DbContextsforIDapperContextintegration and database operations. - Relies on internal mapping and helper classes in the
DapperLibrary.MergeUtilityproject; no external database-specific code is required by callers. - The project contains conditional compilation to support older .NET Framework targets and modern .NET runtimes. Use the build appropriate assemblies for your runtime.
Notes
- The merge implementation is intended for typical OLTP-sized datasets. For very large datasets consider batching or ETL-style approaches.
- SQL generation and parameter handling are provider-aware but edge-case SQL dialect differences may require inspection of the dumped statements (
DumperInternal) when diagnosing issues.
License / Contributing
See repository root for license and contribution guidelines.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net35 is compatible. net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 3.5
- Net4x.CoreLibrary.Logging (>= 2.5.0.4)
- Net4x.DapperLibrary.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.Extensions.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.StatementBuilder (>= 1.9.9.6)
- Newtonsoft.Json (>= 13.0.4)
-
.NETFramework 4.0
- Net4x.CoreLibrary.Logging (>= 2.5.0.4)
- Net4x.DapperLibrary.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.Extensions.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.StatementBuilder (>= 1.9.9.6)
- Newtonsoft.Json (>= 13.0.4)
-
.NETFramework 4.5
- Net4x.CoreLibrary.Logging (>= 2.5.0.4)
- Net4x.DapperLibrary.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.Extensions.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.StatementBuilder (>= 1.9.9.6)
- Newtonsoft.Json (>= 13.0.4)
-
.NETFramework 4.6.1
- Azure.Identity (>= 1.13.1)
- Microsoft.Data.SqlClient (>= 5.2.1)
- Net4x.CoreLibrary.Logging (>= 2.5.0.4)
- Net4x.DapperLibrary.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.Extensions.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.StatementBuilder (>= 1.9.9.6)
- Newtonsoft.Json (>= 13.0.4)
- System.Data.Odbc (>= 7.0.0)
- System.Data.OleDb (>= 7.0.0)
- System.Data.SqlClient (>= 4.8.6)
- System.Drawing.Common (>= 7.0.0)
-
.NETStandard 2.0
- Azure.Identity (>= 1.13.1)
- Microsoft.Data.SqlClient (>= 5.2.1)
- Net4x.CoreLibrary.Logging (>= 2.5.0.4)
- Net4x.DapperLibrary.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.Extensions.Base (>= 1.9.9.6)
- Net4x.DapperLibrary.StatementBuilder (>= 1.9.9.6)
- Newtonsoft.Json (>= 13.0.4)
- System.Configuration.ConfigurationManager (>= 9.0.0)
- System.Data.Odbc (>= 7.0.0)
- System.Data.OleDb (>= 7.0.0)
- System.Data.SqlClient (>= 4.8.6)
- System.Drawing.Common (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.9.9.6 | 36 | 1/6/2026 |
| 1.9.9.5 | 37 | 1/6/2026 |
| 1.9.9.4 | 33 | 1/6/2026 |
| 1.9.9.3 | 85 | 1/5/2026 |
| 1.9.9.2 | 105 | 12/30/2025 |
| 1.9.9.1 | 114 | 12/30/2025 |
| 1.9.9 | 171 | 12/22/2025 |
| 1.6.0.12 | 128 | 12/12/2025 |
| 1.6.0.11 | 121 | 12/12/2025 |
| 1.6.0.10 | 455 | 12/9/2025 |
| 1.6.0.9 | 204 | 12/4/2025 |
| 1.6.0.8 | 198 | 12/4/2025 |
| 1.6.0.7 | 270 | 11/30/2025 |
| 1.6.0.6 | 204 | 11/27/2025 |
| 1.6.0.5 | 233 | 11/22/2025 |
| 1.6.0.4 | 170 | 11/16/2025 |
| 1.6.0.3 | 183 | 11/15/2025 |
| 1.6.0.2 | 279 | 11/14/2025 |
| 1.6.0.1 | 253 | 11/10/2025 |
| 1.6.0 | 211 | 11/9/2025 |
| 1.5.0.3 | 198 | 11/5/2025 |
| 1.5.0.2 | 203 | 11/3/2025 |
| 1.5.0.1 | 201 | 11/3/2025 |
| 1.5.0 | 167 | 10/26/2025 |
| 1.4.1.6 | 202 | 10/24/2025 |
| 1.4.1.5 | 191 | 10/22/2025 |
| 1.4.1.4 | 199 | 10/22/2025 |
| 1.4.1.2 | 201 | 5/30/2025 |
| 1.4.1.1 | 195 | 4/30/2025 |
| 1.4.1 | 209 | 4/30/2025 |
| 1.4.0 | 238 | 3/31/2025 |
| 1.1.0 | 235 | 8/26/2023 |