LinqBuilder.EFCore
4.1.0
dotnet add package LinqBuilder.EFCore --version 4.1.0
NuGet\Install-Package LinqBuilder.EFCore -Version 4.1.0
<PackageReference Include="LinqBuilder.EFCore" Version="4.1.0" />
<PackageVersion Include="LinqBuilder.EFCore" Version="4.1.0" />
<PackageReference Include="LinqBuilder.EFCore" />
paket add LinqBuilder.EFCore --version 4.1.0
#r "nuget: LinqBuilder.EFCore, 4.1.0"
#:package LinqBuilder.EFCore@4.1.0
#addin nuget:?package=LinqBuilder.EFCore&version=4.1.0
#tool nuget:?package=LinqBuilder.EFCore&version=4.1.0
LinqBuilder.EFCore
Async Entity Framework Core methods for LinqBuilder specifications. This package adds AnyAsync, AllAsync, CountAsync, FirstAsync, FirstOrDefaultAsync, SingleAsync and SingleOrDefaultAsync overloads that take an ISpecification<T>. LinqBuilder is an implementation of the specification pattern for LINQ.
int adults = await db.People.CountAsync(new IsAdult());
List<Person> page = await db.People.ExeSpec(spec).ToListAsync();
Full documentation: github.com/Baune8D/LinqBuilder
Getting started
1. Install
dotnet add package LinqBuilder.EFCore
This also installs LinqBuilder.
2. Write a specification
using System;
using System.Linq.Expressions;
using LinqBuilder;
public class IsAdult : Specification<Person>
{
public override Expression<Func<Person, bool>> AsExpression()
{
return person => person.Age >= 18;
}
}
3. Query
using LinqBuilder;
using LinqBuilder.EFCore;
using LinqBuilder.OrderBy;
using Microsoft.EntityFrameworkCore;
var spec = new IsAdult()
.OrderBy(OrderSpec<Person, string>.New(p => p.LastName))
.Paginate(pageNo: 1, pageSize: 20);
List<Person> page = await db.People.ExeSpec(spec).ToListAsync(); // filtered, sorted and paged in SQL
int total = await db.People.CountAsync(spec); // filter only: all adults
bool anyAdults = await db.People.AnyAsync(new IsAdult());
ExeSpec returns an IQueryable<T>, so EF Core's own methods, such as ToListAsync, work on the result.
Methods
Extension methods on IQueryable<T>, in the LinqBuilder.EFCore namespace:
| Method | Returns |
|---|---|
AnyAsync(spec) |
Task<bool> |
AllAsync(spec) |
Task<bool> |
CountAsync(spec) |
Task<int> |
FirstAsync(spec) |
Task<T> |
FirstOrDefaultAsync(spec) |
Task<T?> |
SingleAsync(spec) |
Task<T> |
SingleOrDefaultAsync(spec) |
Task<T?> |
- They use only the filter of the specification and ignore its sort keys,
SkipandTake. - They have no
CancellationTokenparameter. To pass one, filter withWhere(spec)and call EF Core's method:await db.People.Where(spec).CountAsync(cancellationToken). - For lists, and for results in the specification's sort order, use
ExeSpecwith EF Core's methods:await db.People.ExeSpec(spec).ToListAsync(cancellationToken).
Compatibility
Each target framework uses the matching EF Core version:
| Target framework | EF Core |
|---|---|
| .NET 8 | 8.x |
| .NET 9 | 9.x |
| .NET 10 | 10.x |
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 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 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. |
-
net10.0
- LinqBuilder (>= 4.1.0)
- Microsoft.EntityFrameworkCore (>= 10.0.0 && < 11.0.0)
- Microsoft.Extensions.Caching.Memory (>= 10.0.0 && < 11.0.0)
-
net8.0
- LinqBuilder (>= 4.1.0)
- Microsoft.EntityFrameworkCore (>= 8.0.0 && < 9.0.0)
- Microsoft.Extensions.Caching.Memory (>= 8.0.1 && < 9.0.0)
-
net9.0
- LinqBuilder (>= 4.1.0)
- Microsoft.EntityFrameworkCore (>= 9.0.0 && < 10.0.0)
- Microsoft.Extensions.Caching.Memory (>= 9.0.0 && < 10.0.0)
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 |
|---|---|---|
| 4.1.0 | 111 | 11/2/2026 |
| 4.0.0 | 383 | 1/8/2026 |
| 3.2.0 | 4,006 | 12/30/2024 |
| 3.1.0 | 2,434 | 5/5/2024 |
| 3.0.1 | 404 | 10/18/2023 |
| 3.0.0 | 256 | 10/17/2023 |
| 2.1.2 | 1,305 | 4/14/2022 |
| 2.1.1 | 625 | 4/13/2022 |
| 2.1.0 | 622 | 4/13/2022 |
| 2.0.0 | 1,237 | 1/19/2021 |
| 1.0.1 | 690 | 11/3/2020 |
| 1.0.0 | 709 | 11/3/2020 |
| 0.16.1 | 18,426 | 8/29/2019 |
| 0.15.0 | 1,828 | 12/4/2018 |
| 0.14.0 | 1,058 | 12/3/2018 |
| 0.13.0 | 1,464 | 9/17/2018 |
| 0.12.1 | 1,358 | 7/18/2018 |
| 0.12.0 | 1,545 | 7/18/2018 |
| 0.11.1 | 1,527 | 7/18/2018 |
| 0.11.0 | 1,630 | 6/24/2018 |