NPredicateBuilder 5.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NPredicateBuilder --version 5.1.1                
NuGet\Install-Package NPredicateBuilder -Version 5.1.1                
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="NPredicateBuilder" Version="5.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NPredicateBuilder --version 5.1.1                
#r "nuget: NPredicateBuilder, 5.1.1"                
#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.
// Install NPredicateBuilder as a Cake Addin
#addin nuget:?package=NPredicateBuilder&version=5.1.1

// Install NPredicateBuilder as a Cake Tool
#tool nuget:?package=NPredicateBuilder&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 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.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on NPredicateBuilder:

Package Downloads
NPredicateBuilder.EF

NPredicateBuilder extensions for Entity Framework.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
5.3.0 336 1/21/2024
5.2.1 226 12/30/2023
5.2.0 178 12/30/2023
5.1.1 246 6/12/2023
5.1.0 211 6/11/2023
5.0.0 665 7/9/2022
4.0.0 419 1/15/2021
3.1.0 983 4/3/2020
3.0.1 776 9/19/2019