Net4x.DapperLibrary.Extensions.Archive 1.9.9.6

dotnet add package Net4x.DapperLibrary.Extensions.Archive --version 1.9.9.6
                    
NuGet\Install-Package Net4x.DapperLibrary.Extensions.Archive -Version 1.9.9.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Net4x.DapperLibrary.Extensions.Archive" Version="1.9.9.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Net4x.DapperLibrary.Extensions.Archive" Version="1.9.9.6" />
                    
Directory.Packages.props
<PackageReference Include="Net4x.DapperLibrary.Extensions.Archive" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Net4x.DapperLibrary.Extensions.Archive --version 1.9.9.6
                    
#r "nuget: Net4x.DapperLibrary.Extensions.Archive, 1.9.9.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Net4x.DapperLibrary.Extensions.Archive@1.9.9.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Net4x.DapperLibrary.Extensions.Archive&version=1.9.9.6
                    
Install as a Cake Addin
#tool nuget:?package=Net4x.DapperLibrary.Extensions.Archive&version=1.9.9.6
                    
Install as a Cake Tool

DapperLibrary.Extensions.Archive

Utilities to create archive tables and move old data to archive tables when saving DataTable/DataSet instances via IDapperContext.

Overview

  • Purpose: provide a standard workflow for archiving table contents before replacing or truncating the original table. The archive helpers can create archive tables (if needed), enrich primary keys with additional columns (e.g. modified date), delete archived rows from the original table and persist archived rows to the archive table.
  • Prefix-based: archive table names are produced by adding a configured prefix to the original table name.

Main types

  • ArchiveSetting

    • Configuration model that contains:
      • PrefixToArchive and PrefixArchived � prefixes used to identify tables to archive and the archived target name.
      • IsArchiveEnabled � toggle archiving behaviour.
      • PrimaryKeysForTableType � strategy for determining primary keys for tables (IPrimaryKeysForTableType from DapperLibrary.Data).
  • ITableArchiver

    • Interface describing archive operations that can be implemented to customize archiving behavior. Main methods:
      • ArchiveOldTableAsync(...) � move or save existing rows to the archive and remove them from the original table.
      • CreateArchiveTableIfNotExists(...) � ensure the archive table exists with the appropriate schema before archiving.
  • TableArchiver (default implementation)

    • Implements ITableArchiver and provides the default archiving logic:
      • Loads the source table via IDapperContext.LoadDataTableFromNameAsync.
      • Creates the archive table if missing.
      • Enriches primary keys (adds any columnsToAdd as part of the composite primary key) so archived rows can include e.g. modification timestamps.
      • Deletes the archived rows from the original table in chunks and saves archived rows to the archive table.

Extension methods

  • SaveDataTableExtension / SaveDataSetExtension

    • Provide SaveDataTable/SaveDataSet and async overloads that integrate archiving into the save flow.
    • Default overloads use the context's ConnectionStringToRead but connection-specific methods are available.
    • Parameters commonly used:
      • primaryKeySize � size to use when creating primary key columns on new tables.
      • chunkSize � number of rows to delete at once when removing archived rows from the original table.
      • columnsToAdd � extra columns that get added to the primary key of archived rows (for example ModifiedDate).
      • emptyTable � whether to empty/replace the original table before saving.
      • addDateSuffix � append a date suffix to the table name when saving (useful to avoid name collisions).
      • rowPreProcessor � optional IRowPreProcessor called before save to modify rows (e.g. generate UUIDs).
      • tableArchiver � custom ITableArchiver implementation (if null, default TableArchiver logic is used).
  • CreateTableExtension / CreateOrEmptyOriginalAndSaveTableExtension

    • Helpers to create or recreate the target table and then save the data while optionally archiving the old contents.

Behavior notes

  • Archiving is opt-in via the ArchiveSetting.IsArchiveEnabled flag; when disabled the archiver is a no-op.
  • The archiving logic guards against double-archiving by skipping tables whose names already start with the configured PrefixToArchive or PrefixArchived.
  • The default archiver sets archive table primary keys using the configured IPrimaryKeysForTableType and appends any specified columnsToAdd to the composite primary key.
  • Deletions from the original table are performed in chunks to avoid locking large operations.

Example

var archiveSetting = new ArchiveSetting("ToArchive_", "Archived_", true, new MyPrimaryKeysForTableType());

// Save a single DataTable while archiving old rows:
var (affectedRows, sql) = await dapperContext.SaveDataTableAsync(
    dataTable,
    rowPreProcessor: null,
    primaryKeySize: 50,
    emptyTable: false,
    archiveSetting: archiveSetting,
    tableArchiver: null, // use default TableArchiver
    chunkSize: 1000,
    addDateSuffix: false
);

// Or save an entire DataSet and archive each table as needed:
var (totalAffected, sqlStatements) = await dapperContext.SaveDataSetAsync(
    dataSet,
    connectionStringName: "MyConnection",
    rowPreProcessor: null,
    primaryKeySize: 50,
    archiveSetting: archiveSetting,
    tableArchiver: null,
    emptyTable: false,
    chunkSize: 1000
);

Dependencies and compatibility

  • Built on top of DapperLibrary.DbContexts and DapperLibrary.Data abstractions.
  • This project contains code paths for older .NET Framework targets and modern .NET Standard/.NET runtimes; include compatible DapperLibrary assemblies for your target framework.

Extensibility

  • Implement ITableArchiver for custom archiving strategies (e.g. copy to external storage, compress archived rows, or transmit them to a separate archival database).
  • Provide a custom IPrimaryKeysForTableType implementation to control how primary keys are detected or assigned for different table types.

License / Contributing

See repository root for license and contribution guidelines.

Product 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 is compatible. 
.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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 72 1/6/2026
1.9.9.5 72 1/6/2026
1.9.9.4 76 1/6/2026
1.9.9.3 84 1/5/2026
1.9.9.2 83 12/30/2025
1.9.9.1 84 12/30/2025
1.9.9 174 12/22/2025
1.6.0.12 123 12/12/2025
1.6.0.11 115 12/12/2025