NooberCong.DynamicInclude 1.1.1

.NET 5.0
Install-Package NooberCong.DynamicInclude -Version 1.1.1
dotnet add package NooberCong.DynamicInclude --version 1.1.1
<PackageReference Include="NooberCong.DynamicInclude" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NooberCong.DynamicInclude --version 1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: NooberCong.DynamicInclude, 1.1.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install NooberCong.DynamicInclude as a Cake Addin
#addin nuget:?package=NooberCong.DynamicInclude&version=1.1.1

// Install NooberCong.DynamicInclude as a Cake Tool
#tool nuget:?package=NooberCong.DynamicInclude&version=1.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Extension method for dynamically including navigation properties in EF Core

Deep nested includes

Syntax:

// Single deep include
includePropName1.includePropName2

// Multiple child includes
includePropName1.(includePropName2, includePropName3)

Example:

context.Owners.DynamicInclude("Pets.(Snacks, Toys.Manufacturer)")

DynamicInclude is case-insensitive

// will also work
context.Owners.DynamicInclude("pets.(sNacks, tOys.manuFacturer)");

Normal EF Core equivalent:

context.Owners
	.Include(o => o.Pets)
		.ThenInclude(p => p.Snacks)
	.Include(o => o.Pets)
		.ThenInclude(p => p.Toys)
			.ThenInclude(t => t.Manufacturer)

Adding OrderBy to child includes

Syntax:

includePropname<[+-]orderPropName1, [+-]orderPropName2>

Example:

context.Owners.DynamicInclude("Pets<Name, -Weight>.Snacks<Id>")

Normal EF Core equivalent:

context.Owners
	.Include(o => o.Pets.OrderBy(p => p.Name).ThenByDescending(o => p.Weight))
		ThenInclude(p => p.Snacks.OrderBy(sn => sn.Id))

Skipping/Taking in child includes

Syntax:

// Take t elements
includePropName[:t]

// Skip s elements
includePropName[s:]

// Skip s and take (t - s) elements
includePropName[s:t]

Example:

context.Owners.DynamicInclude("Pets<-Weight>[:3].Snacks[1:4]")

Normal EF Core equivalent:

context.Owners
	.Include(o => o.Pets.OrderByDescending(p => p.Weights).Take(3))
		ThenInclude(p => p.Snacks.Skip(1).Take(3))

Note

If you experience performance issues, consider adding AsSplitQuery() to query

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
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.1.1 120 12/14/2021
1.1.0 94 12/14/2021
1.0.3 264 12/11/2021
1.0.2 104 12/11/2021
1.0.1 109 12/11/2021
1.0.0 104 12/11/2021