CodeOfChaos.Extensions.EntityFrameworkCore
0.63.0
Prefix Reserved
See the version list below for details.
dotnet add package CodeOfChaos.Extensions.EntityFrameworkCore --version 0.63.0
NuGet\Install-Package CodeOfChaos.Extensions.EntityFrameworkCore -Version 0.63.0
<PackageReference Include="CodeOfChaos.Extensions.EntityFrameworkCore" Version="0.63.0" />
<PackageVersion Include="CodeOfChaos.Extensions.EntityFrameworkCore" Version="0.63.0" />
<PackageReference Include="CodeOfChaos.Extensions.EntityFrameworkCore" />
paket add CodeOfChaos.Extensions.EntityFrameworkCore --version 0.63.0
#r "nuget: CodeOfChaos.Extensions.EntityFrameworkCore, 0.63.0"
#:package CodeOfChaos.Extensions.EntityFrameworkCore@0.63.0
#addin nuget:?package=CodeOfChaos.Extensions.EntityFrameworkCore&version=0.63.0
#tool nuget:?package=CodeOfChaos.Extensions.EntityFrameworkCore&version=0.63.0
CodeOfChaos.Extensions.EntityFrameworkCore
CodeOfChaos.Extensions.EntityFrameworkCore is a library that extends LINQ capabilities in Entity Framework Core. It
introduces conditional extensions for operations like Include, Where, OrderBy, and others. These methods enable
dynamic query building, improving flexibility and readability when working with Entity Framework Core.
Features
Conditional Query Building
Enhance IQueryable queries with conditional functionality:
- Conditional Includes:
- Dynamically include related entities based on runtime conditions.
- Conditional Filters:
- Apply
Whereclauses only when a condition is met.
- Apply
- Conditional Sorting:
- Apply
OrderByclauses conditionally or use optional order expressions.
- Apply
- Conditional Pagination:
- Apply
Take, including support for ranges.
- Apply
Installation
This library targets .NET 9.0 and requires C# 13.0. Ensure your project meets these requirements before using.
Add the dependency to your project via NuGet:
dotnet add package CodeOfChaos.Extensions.EntityFrameworkCore
Usage
Here’s how you can leverage the library for dynamic query building in Entity Framework Core:
Conditional Include
Dynamically include related entities only when needed:
using Microsoft.EntityFrameworkCore;
var query = dbContext.Users.ConditionalInclude(isAdmin, u => u.Roles);
Conditional Where
Apply a filter based on runtime conditions:
var query = dbContext.Users.ConditionalWhere(filterByEmail, u => u.Email == searchEmail);
Conditional OrderBy
Use conditional sorting:
var query = dbContext.Users.ConditionalOrderBy(applySorting, u => u.LastName);
Or, with a comparer:
var query = dbContext.Users.ConditionalOrderBy(applySorting, u => u.LastName, StringComparer.OrdinalIgnoreCase);
Conditional Take
Limit the results dynamically:
var query = dbContext.Users.ConditionalTake(applyPagination, 50);
Or, with a range:
var query = dbContext.Users.ConditionalTake(applyPagination, ..10);
Contributing
Feel free to fork and contribute to the project by submitting pull requests. When contributing, ensure your changes align with the project’s coding standards.
| 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
- Microsoft.EntityFrameworkCore (>= 9.0.4)
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.87.2 | 201 | 11/24/2025 |
| 0.87.0 | 389 | 11/20/2025 |
| 0.86.0 | 393 | 11/19/2025 |
| 0.85.0 | 322 | 11/17/2025 |
| 0.84.6 | 222 | 11/14/2025 |
| 0.83.2 | 176 | 10/22/2025 |
| 0.83.1 | 119 | 9/12/2025 |
| 0.81.1 | 140 | 9/5/2025 |
| 0.81.0 | 178 | 9/3/2025 |
| 0.80.0 | 108 | 8/23/2025 |
| 0.79.1 | 164 | 8/19/2025 |
| 0.79.0 | 173 | 8/19/2025 |
| 0.77.3 | 128 | 8/15/2025 |
| 0.75.0 | 123 | 8/15/2025 |
| 0.74.0 | 179 | 8/13/2025 |
| 0.73.0 | 168 | 8/13/2025 |
| 0.72.0 | 173 | 8/13/2025 |
| 0.71.0 | 174 | 8/13/2025 |
| 0.70.1 | 355 | 7/20/2025 |
| 0.70.0 | 351 | 7/20/2025 |
| 0.69.0 | 103 | 7/5/2025 |
| 0.68.0 | 245 | 5/19/2025 |
| 0.67.0 | 195 | 5/19/2025 |
| 0.66.1 | 132 | 5/9/2025 |
| 0.66.0 | 174 | 5/5/2025 |
| 0.65.0 | 180 | 4/30/2025 |
| 0.64.0 | 212 | 4/23/2025 |
| 0.63.0 | 192 | 4/23/2025 |
| 0.62.0 | 205 | 4/23/2025 |
| 0.61.0 | 207 | 4/23/2025 |
| 0.60.0 | 153 | 4/18/2025 |
| 0.59.1 | 178 | 4/18/2025 |
| 0.59.0 | 225 | 4/17/2025 |
| 0.58.0 | 238 | 4/17/2025 |
| 0.57.0 | 141 | 4/5/2025 |
| 0.56.0 | 143 | 3/29/2025 |
| 0.55.0 | 171 | 3/26/2025 |
| 0.54.0 | 498 | 3/26/2025 |
| 0.53.0 | 449 | 3/24/2025 |
| 0.52.0 | 449 | 3/24/2025 |
| 0.51.0 | 199 | 3/22/2025 |
| 0.50.0 | 165 | 3/20/2025 |
| 0.49.0 | 190 | 3/20/2025 |
| 0.48.0 | 172 | 3/18/2025 |
| 0.47.0 | 189 | 3/18/2025 |
| 0.46.0 | 184 | 3/18/2025 |
| 0.45.0 | 180 | 3/18/2025 |
| 0.44.0 | 190 | 3/17/2025 |
| 0.43.0 | 132 | 3/14/2025 |
| 0.42.3 | 251 | 3/4/2025 |
| 0.42.3-preview.1 | 191 | 3/4/2025 |
| 0.41.2 | 257 | 3/4/2025 |
| 0.41.1 | 239 | 3/3/2025 |
| 0.41.0 | 146 | 2/26/2025 |
| 0.40.1 | 145 | 2/24/2025 |
| 0.40.0 | 136 | 2/24/2025 |
| 0.39.4 | 149 | 2/20/2025 |
| 0.39.3 | 141 | 2/20/2025 |
| 0.39.2 | 139 | 2/20/2025 |
| 0.39.1 | 143 | 2/20/2025 |
| 0.39.0 | 152 | 2/18/2025 |
| 0.37.2 | 158 | 2/16/2025 |
| 0.37.1 | 145 | 2/16/2025 |
| 0.36.4 | 153 | 2/14/2025 |
| 0.36.0 | 144 | 2/14/2025 |
| 0.35.0 | 138 | 2/8/2025 |
| 0.34.0 | 130 | 2/5/2025 |
| 0.33.0 | 145 | 2/5/2025 |
| 0.32.0 | 154 | 2/1/2025 |
| 0.31.0 | 131 | 1/29/2025 |
| 0.30.0 | 134 | 1/8/2025 |
| 0.29.2 | 158 | 1/4/2025 |
| 0.29.0 | 165 | 1/3/2025 |
| 0.28.2 | 159 | 1/1/2025 |
| 0.27.1 | 162 | 12/31/2024 |
| 0.27.0 | 146 | 12/29/2024 |
| 0.26.0 | 141 | 12/28/2024 |
| 0.25.0 | 144 | 12/28/2024 |
| 0.24.3 | 134 | 12/27/2024 |
| 0.24.2 | 133 | 12/27/2024 |
| 0.24.1 | 137 | 12/27/2024 |
| 0.24.0 | 120 | 12/27/2024 |
| 0.23.1 | 145 | 12/27/2024 |
| 0.23.0 | 129 | 12/27/2024 |
| 0.22.2 | 119 | 12/27/2024 |
| 0.22.0 | 134 | 12/23/2024 |
| 0.21.0 | 153 | 12/22/2024 |
| 0.20.0-preview.1 | 81 | 12/21/2024 |