LinqBuilder.EF6 4.1.0

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

LinqBuilder.EF6

Async Entity Framework 6 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.EF6

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 System.Data.Entity;
using LinqBuilder;
using LinqBuilder.EF6;
using LinqBuilder.OrderBy;

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 Entity Framework's own methods, such as ToListAsync, work on the result.

Methods

Extension methods on IQueryable<T>, in the LinqBuilder.EF6 namespace:

Method Returns
AnyAsync(spec) Task<bool>
AllAsync(spec) Task<bool>
CountAsync(spec) Task<int>
FirstAsync(spec) Task<T>
FirstOrDefaultAsync(spec) Task<T>, with null if nothing matches
SingleAsync(spec) Task<T>
SingleOrDefaultAsync(spec) Task<T>, with null if nothing matches
  • 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 Entity Framework's method: await db.People.Where(spec).CountAsync(cancellationToken).
  • For lists, and for results in the specification's sort order, use ExeSpec with Entity Framework's methods: await db.People.ExeSpec(spec).ToListAsync(cancellationToken).

Compatibility

The package targets .NET Standard 2.1 and depends on Entity Framework 6.5.2 or later. It runs on .NET Core 3.0 and later (including .NET 8, 9 and 10), but not on .NET Framework, which doesn't support .NET Standard 2.1.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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 109 11/2/2026
4.0.0 270 1/8/2026
3.2.0 285 12/30/2024
3.1.0 263 5/5/2024
3.0.1 402 10/18/2023
3.0.0 283 10/17/2023
2.1.2 704 4/14/2022
2.1.1 640 4/13/2022
2.1.0 642 4/13/2022
2.0.0 665 1/19/2021
1.0.1 7,356 11/3/2020
1.0.0 670 11/3/2020
0.16.1 834 8/29/2019
0.15.0 1,013 12/4/2018
0.14.0 998 12/3/2018
0.13.0 1,376 9/17/2018
0.12.1 1,739 7/18/2018
0.12.0 1,246 7/18/2018
0.11.1 1,246 7/18/2018
0.11.0 1,585 6/24/2018
Loading failed