NPredicateBuilder.EF 5.1.1

There is a newer version of this package available.
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
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.EF" Version="5.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NPredicateBuilder.EF --version 5.1.1
#r "nuget: NPredicateBuilder.EF, 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.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 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. 
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
5.3.0 109 1/21/2024
5.2.1 129 12/30/2023
5.2.0 93 12/30/2023
5.1.1 123 6/12/2023
5.1.0 118 6/12/2023
5.0.0 400 7/9/2022
4.0.0 360 1/15/2021
3.1.0 561 4/3/2020
3.0.0 520 9/21/2019