Soenneker.Extensions.Dictionary 4.0.647

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Extensions.Dictionary --version 4.0.647
                    
NuGet\Install-Package Soenneker.Extensions.Dictionary -Version 4.0.647
                    
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="Soenneker.Extensions.Dictionary" Version="4.0.647" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Extensions.Dictionary" Version="4.0.647" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Extensions.Dictionary" />
                    
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 Soenneker.Extensions.Dictionary --version 4.0.647
                    
#r "nuget: Soenneker.Extensions.Dictionary, 4.0.647"
                    
#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 Soenneker.Extensions.Dictionary@4.0.647
                    
#: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=Soenneker.Extensions.Dictionary&version=4.0.647
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Extensions.Dictionary&version=4.0.647
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Extensions.Dictionary

Extensions for flattening dictionary values, merging keyed objects, mapping string/object data to objects, and reverse value lookup.

Installation

dotnet add package Soenneker.Extensions.Dictionary

Flatten lists of values

using Soenneker.Extensions.Dictionary;

var groups = new Dictionary<string, List<int>>
{
    ["odd"] = [1, 3],
    ["even"] = [2, 4]
};

List<int> values = groups.ToFlattenedValuesList(); // 1, 3, 2, 4

The result follows dictionary enumeration order and then each list's order. Null lists are skipped, and the source lists are not changed.

Add or update ranges

var people = new[]
{
    new Person("a", "Alice"),
    new Person("b", "Bob")
};

var byId = new Dictionary<string, Person>();
byId.AddRange(people, person => person.Id);

public sealed record Person(string Id, string Name);

AddRange() compiles the expression selector on each call. Use AddRangeCompiled() with a reusable Func<TValue, TKey> in repeated or hot paths. Both methods mutate the destination, add missing keys, and replace existing values. If multiple input items produce the same key, the last item wins.

AddDictionary(source, dictionary) applies the same add-or-replace behavior to every entry from another dictionary.

Map a dictionary to an object

var data = new Dictionary<string, object>
{
    ["name"] = "Jane",
    ["Age"] = "42"
};

PersonDto person = data.ToObject<PersonDto>();
// person.Name == "Jane"
// person.Age == 42

public sealed class PersonDto
{
    public string? Name { get; set; }
    public int Age { get; set; }
}

Property names are matched case-insensitively. Directly assignable values are used as-is; otherwise, Convert.ChangeType is attempted. Unknown properties, read-only properties, nulls that cannot be assigned, and values that fail ordinary type conversion are skipped. This is a lightweight mapper, not a serializer: nested objects, collections, enums, and nullable conversions may require explicit preparation.

Find a key by value

bool found = byId.TryGetKeyFromValue(people[0], out string? key);

TryGetKeyFromValue() uses reference equality first and then Equals. When several keys have equal values, it returns the first match in dictionary enumeration order. When no value matches, it returns false and sets the output key to its default value.

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

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Extensions.Dictionary:

Package Downloads
Soenneker.Swashbuckle.Authentication

A middleware implementing basic authentication and RBAC support for Swashbuckle (Swagger)

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.659 0 9/4/2026
4.0.658 37 9/3/2026
4.0.657 40 9/2/2026
4.0.656 53 9/2/2026
4.0.655 49 9/2/2026
4.0.654 56 9/1/2026
4.0.653 42 9/1/2026
4.0.652 58 9/1/2026
4.0.651 88 8/31/2026
4.0.650 125 8/31/2026
4.0.649 82 8/31/2026
4.0.648 150 8/30/2026
4.0.647 78 8/30/2026
4.0.646 77 8/30/2026
4.0.645 77 8/30/2026
4.0.644 79 8/29/2026
4.0.643 80 8/29/2026
4.0.642 82 8/29/2026
4.0.641 85 8/29/2026
4.0.640 204 8/27/2026
Loading failed

Update dependency Soenneker.Reflection.Cache to 4.0.665 (#1111)