LinqBuilder.EFCore 4.1.0

dotnet add package LinqBuilder.EFCore --version 4.1.0
                    
NuGet\Install-Package LinqBuilder.EFCore -Version 4.1.0
                    
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="LinqBuilder.EFCore" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LinqBuilder.EFCore" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="LinqBuilder.EFCore" />
                    
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 LinqBuilder.EFCore --version 4.1.0
                    
#r "nuget: LinqBuilder.EFCore, 4.1.0"
                    
#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 LinqBuilder.EFCore@4.1.0
                    
#: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=LinqBuilder.EFCore&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=LinqBuilder.EFCore&version=4.1.0
                    
Install as a Cake Tool

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, Skip and Take.
  • They have no CancellationToken parameter. To pass one, filter with Where(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 ExeSpec with 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

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
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
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
Loading failed