NPredicateBuilder.EF
5.1.1
See the version list below for details.
dotnet add package NPredicateBuilder.EF --version 5.1.1
NuGet\Install-Package NPredicateBuilder.EF -Version 5.1.1
<PackageReference Include="NPredicateBuilder.EF" Version="5.1.1" />
paket add NPredicateBuilder.EF --version 5.1.1
#r "nuget: NPredicateBuilder.EF, 5.1.1"
// Install NPredicateBuilder.EF as a Cake Addin
#addin nuget:?package=NPredicateBuilder.EF&version=5.1.1
// Install NPredicateBuilder.EF as a Cake Tool
#tool nuget:?package=NPredicateBuilder.EF&version=5.1.1
NPredicateBuilder
Simple, testable, LINQ queries.
NPredicateBuilder allows you to build small and easily testable Where and Order clauses that you can chain together to create complex queries.
Quick Overview
class PeopleQuery : BaseQuery<People>
{
public PeopleQuery AndNameIs(string name)
{
AddAndCriteria(x => x.Name == name);
return this;
}
public PeopleQuery OrAgeIsOver(int age)
{
AddOrCriteria(x => x.Age > age);
return this;
}
}
Then create a complex query by chaining them together.
var peopleQuery = new PeopleQuery()
.AndNameIs("brad")
.OrAgeIsOver(10);
Pass your queries and orders to the designated extension method.
var result = ApplicationContext.People
.NPredicateBuilderEFWhere(peopleQuery);
Because it's just an extension method, it behaves like any other LINQ to Object or LINQ to Entities query.
var result = ApplicationContext.People
.NPredicateBuilderEFWhere(peopleQuery)
.Skip(10)
.Take(15)
.Select(x => new { x.Name, x.Age })
.ToList();
NPredicateBuilder can easily be added to any existing or new codebase, no matter what size!
NPredicateBuilder can simplify Ordering in the same way it handles Queries.
Install NPredicateBuilder
The best way is to install with NuGet.
In your domain layer.
Install-Package NPredicateBuilder
If you are doing LINQ to Entities, install the following in your data access layer.
Install-Package NPredicateBuilder.EF
Documentation
Any and all documentation can be viewed in the wiki.
It's only a five minute read!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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. |
.NET Core | netcoreapp2.1 is compatible. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Framework | net48 is compatible. net481 was computed. |
-
.NETCoreApp 2.1
- LinqKit.Microsoft.EntityFrameworkCore (>= 2.1.2)
- NPredicateBuilder (>= 5.1.1)
-
.NETCoreApp 3.1
- LinqKit.Microsoft.EntityFrameworkCore (>= 3.2.2)
- NPredicateBuilder (>= 5.1.1)
-
.NETFramework 4.8
- LinqKit.EntityFramework (>= 1.2.2)
- NPredicateBuilder (>= 5.1.1)
-
net5.0
- LinqKit.Microsoft.EntityFrameworkCore (>= 5.1.2)
- NPredicateBuilder (>= 5.1.1)
-
net6.0
- LinqKit.Microsoft.EntityFrameworkCore (>= 6.1.2)
- NPredicateBuilder (>= 5.1.1)
-
net7.0
- LinqKit.Microsoft.EntityFrameworkCore (>= 7.1.4)
- NPredicateBuilder (>= 5.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.