DaxSharp 0.5.5
dotnet add package DaxSharp --version 0.5.5
NuGet\Install-Package DaxSharp -Version 0.5.5
<PackageReference Include="DaxSharp" Version="0.5.5" />
<PackageVersion Include="DaxSharp" Version="0.5.5" />
<PackageReference Include="DaxSharp" />
paket add DaxSharp --version 0.5.5
#r "nuget: DaxSharp, 0.5.5"
#addin nuget:?package=DaxSharp&version=0.5.5
#tool nuget:?package=DaxSharp&version=0.5.5
DaxSharp
DaxSharp is a .NET utility library that brings DAX-style summarization capabilities to LINQ collections. It offers flexible grouping, filtering, and aggregation of in-memory data structures in a concise, expressive way.
๐ฆ Installation
Install via NuGet:
dotnet add package DaxSharp
๐ Features
- Perform DAX-like SUMMARIZECOLUMNS on in-memory collections.
- Filter data before aggregation.
- Compute multiple aggregation expressions.
- Handle sparse or missing group combinations with Cartesian expansion.
๐งช Usage
SummarizeColumns
Groups and filters items, then computes specified aggregations.
using DaxSharp;
var data = new[]
{
(Product: "Product1", Category: "Category1", IsActive: true, Amount: 10, Quantity: 2),
(Product: "Product1", Category: "Category2", IsActive: true, Amount: 20, Quantity: 3),
(Product: "Product2", Category: "Category1", IsActive: true, Amount: 5, Quantity: 1),
(Product: "Product3", Category: "Category3", IsActive: true, Amount: 15, Quantity: 2)
}.ToList();
var results = data.SummarizeColumns(
item => new { item.Product, item.Category },
(item, group) => item is { IsActive: true, Category: not "Category1" } || group is { Category: not "Category1" },
(items, group) =>
items.ToArray() is { Length: > 0 } array
? array.Sum(x => x.Amount)
: 2
);
The results are:
- Product1, Category2, 20
- Product3, Category3, 15.
SummarizeColumnsCartesian
Same as SummarizeColumns
, but includes all combinations of group keys when aggregations on missing data aren't all null or zero.
using DaxSharp;
var data = new[]
{
(Product: "Product1", Category: "Category1", IsActive: true, Amount: 10, Quantity: 2),
(Product: "Product1", Category: "Category2", IsActive: true, Amount: 20, Quantity: 3),
(Product: "Product2", Category: "Category1", IsActive: true, Amount: 5, Quantity: 1),
(Product: "Product3", Category: "Category3", IsActive: true, Amount: 15, Quantity: 2)
}.ToList();
var results = data.SummarizeColumnsCartesian(
item => new { item.Product, item.Category },
(item, group) => item is { IsActive: true, Category: not "Category1" } || group is { Category: not "Category1" },
(items, group) =>
items.ToArray() is { Length: > 0 } array
? array.Sum(x => x.Amount)
: 2
);
The results are:
- Product1, Category2, 20
- Product2, Category2, 2
- Product3, Category2, 2
- Product1, Category3, 2
- Product2, Category3, 2
- Product3, Category3, 15.
๐ ๏ธ API Reference
SummarizeColumns<T, TGrouped, TExpressions>
IEnumerable<(TGrouped grouped, TExpressions expressions)>
SummarizeColumns<T, TGrouped, TExpressions>(
this IEnumerable<T> items,
Func<T, TGrouped> groupByBuilder,
Func<T?, TGrouped?, bool> filter,
Func<IEnumerable<T>, TGrouped?, TExpressions?> expressions,
int maxCount = int.MaxValue)
where TGrouped : notnull
SummarizeColumnsCartesian<T, TGrouped, TExpressions>
IEnumerable<(TGrouped grouped, TExpressions expressions)>
SummarizeColumnsCartesian<T, TGrouped, TExpressions>(
this IEnumerable<T> items,
Func<T, TGrouped> groupByBuilder,
Func<T?, TGrouped?, bool> filter,
Func<IEnumerable<T>, TGrouped?, TExpressions?> expressions,
int maxCount = int.MaxValue)
where TGrouped : notnull
โ๏ธ Internals
Cartesian expansion in SummarizeColumnsCartesian
fills in missing group key combinations with default expression results.
Skips results with all null expressions unless expansion is required.
๐ License
MIT
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. 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. |
-
net9.0
- No dependencies.
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 |
---|---|---|
0.5.5 | 113 | 6/27/2025 |