Net4x.DapperLibrary.Pivot 1.9.9.26248

dotnet add package Net4x.DapperLibrary.Pivot --version 1.9.9.26248
                    
NuGet\Install-Package Net4x.DapperLibrary.Pivot -Version 1.9.9.26248
                    
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.Pivot" Version="1.9.9.26248" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Net4x.DapperLibrary.Pivot" Version="1.9.9.26248" />
                    
Directory.Packages.props
<PackageReference Include="Net4x.DapperLibrary.Pivot" />
                    
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.Pivot --version 1.9.9.26248
                    
#r "nuget: Net4x.DapperLibrary.Pivot, 1.9.9.26248"
                    
#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.Pivot@1.9.9.26248
                    
#: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.Pivot&version=1.9.9.26248
                    
Install as a Cake Addin
#tool nuget:?package=Net4x.DapperLibrary.Pivot&version=1.9.9.26248
                    
Install as a Cake Tool

DapperLibrary.Pivot

Utilities to pivot a DataTable (rows ? columns) with a small, dependency-light API.

Purpose

  • Provide an in-memory pivot operation on ADO.NET DataTable instances.
  • Support two modes:
    • Count mode: when columnsWithDataToPivot is null, the pivot produces one column per distinct value encountered and a final count column.
    • Value mode: when columnsWithDataToPivot is provided, specified source columns are used to form pivoted columns and values are aggregated or joined per pivot cell.

Main types

  • Pivot � factory with CreateInstance() returning an IPivot implementation.
  • IPivot � interface exposing Pivot(DataTable? sourceDatatable, Dictionary<string,string[]>? columnsWithDataToPivot, params string[] columnsAsPivotPrimaryKey).
  • PivotInternal � internal implementation that performs the pivot logic. It uses ArgumentGetter.Instance to obtain the default CountColumnName and logs exceptions via CoreLibrary.Logging.
  • Extensions: helper methods under Extensions (DataTableHelper, PivotExtensions) assist with table operations and lookups.

API

  • IPivot.Pivot(DataTable? sourceDatatable, Dictionary<string,string[]>? columnsWithDataToPivot, params string[] columnsAsPivotPrimaryKey)
    • sourceDatatable: source rows to pivot. If null, an initial pivot table structure is still returned where possible.
    • columnsWithDataToPivot: when null, the method runs in "count" mode and adds a count column; otherwise it maps source columns to lists of column names whose values become pivoted columns.
      • The dictionary keys are source column names. The dictionary values are arrays of column names whose values should be used when building the pivot cell value for that key.
      • A special dictionary key of "*" may be used to indicate wildcard columns to include additional values for composed cells.
    • columnsAsPivotPrimaryKey: one or more source column names that become the primary key columns of the resulting pivot table. Rows are grouped by these columns when building the pivot.

Behavior notes

  • The pivot result uses the provided columnsAsPivotPrimaryKey as the pivot table primary key. New rows are created when a primary key combination is not present.
  • Column names for pivoted values are taken from the string representation of source cell values. In count mode a numeric count column (default name from configuration, e.g. "Count") is appended.
  • When columnsWithDataToPivot is provided, pivot cell values are either an aggregated count or a joined string of values (joined with " - ") depending on whether mapping lists are empty.
  • The implementation logs exceptions and returns null on error.
  • Default CountColumnName can be configured via ConfigurationLibrary.Arguments (argument name "CountColumnName").

Example

using System.Data;
using DapperLibrary;

var pivot = Pivot.CreateInstance();

// Source table must contain the columns used as primary key and the columns to pivot
var source = new DataTable();
source.Columns.Add("Category", typeof(string));
source.Columns.Add("Type", typeof(string));
source.Columns.Add("Value", typeof(string));

source.Rows.Add("A", "X", "10");
source.Rows.Add("A", "Y", "20");
source.Rows.Add("B", "X", "5");

// columnsWithDataToPivot maps the source column to which columns provide values for the pivot
var columnsWithDataToPivot = new Dictionary<string,string[]>
{
    { "Type", new[] { "Value" } }
};

// Use "Category" as the pivot primary key
var result = pivot.Pivot(source, columnsWithDataToPivot, "Category");

// result will have one row per Category and a column for each distinct Type value (e.g. "X", "Y").
// Each pivot cell contains the joined Value(s) for that Category/Type.

Dependencies

  • The pivot implementation relies on CoreLibrary.Utility.Conversion for conversions and CoreLibrary.Logging for error reporting.
  • ConfigurationLibrary.Arguments is used to read the default CountColumnName setting.

Threading and performance

  • The pivot operation is in-memory and works on DataTable instances; it is not optimized for very large datasets. For large data volumes consider streaming/aggregation approaches.
  • The implementation is not explicitly thread-safe for concurrent mutations of the same DataTable instance.

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.26248 44 9/4/2026
1.9.9.26247 43 9/4/2026
Loading failed