PosInformatique.Foundations.Linq.Expressions 1.5.0

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package PosInformatique.Foundations.Linq.Expressions --version 1.5.0
                    
NuGet\Install-Package PosInformatique.Foundations.Linq.Expressions -Version 1.5.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="PosInformatique.Foundations.Linq.Expressions" Version="1.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PosInformatique.Foundations.Linq.Expressions" Version="1.5.0" />
                    
Directory.Packages.props
<PackageReference Include="PosInformatique.Foundations.Linq.Expressions" />
                    
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 PosInformatique.Foundations.Linq.Expressions --version 1.5.0
                    
#r "nuget: PosInformatique.Foundations.Linq.Expressions, 1.5.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 PosInformatique.Foundations.Linq.Expressions@1.5.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=PosInformatique.Foundations.Linq.Expressions&version=1.5.0
                    
Install as a Cake Addin
#tool nuget:?package=PosInformatique.Foundations.Linq.Expressions&version=1.5.0
                    
Install as a Cake Tool

PosInformatique.Foundations.Linq.Expressions

NuGet version NuGet downloads

Introduction

This package provides expression tree utilities for .NET 8, .NET 9 and .NET 10.

OrExpressionBuilder<T> combines Expression<Func<T, bool>> predicates into a single expression using short-circuiting logical OR, without depending on Entity Framework Core or any other query provider.

The builder is available in the System.Linq.Expressions namespace.

Install

You can install the package from NuGet:

dotnet add package PosInformatique.Foundations.Linq.Expressions

Features

  • Combine any number of predicates using Expression.OrElse.
  • Preserve insertion order and short-circuit evaluation when the expression is executed in memory.
  • Unify predicate parameters while preserving nested lambda parameters.
  • Return an always-true predicate when no expressions are added, so optional filters do not exclude any items.
  • Build expression trees without introducing Expression.Invoke or compiling the predicates.

Usage

using System.Linq.Expressions;

var entities = new[]
{
    new Entity { Name = "A" },
    new Entity { Name = "B" },
    new Entity { Name = "C" },
    new Entity { Name = "D" },
    new Entity { Name = "E" },
};

var builder = new OrExpressionBuilder<Entity>();
builder.Add(entity => entity.Name == "B");
builder.Add(entity => entity.Name == "C");
builder.Add(entity => entity.Name == "E");

Expression<Func<Entity, bool>> predicate = builder.Build();

// Returns the entities named B, C and E.
var results = entities.AsQueryable().Where(predicate).ToArray();

public sealed class Entity
{
    public string Name { get; set; } = string.Empty;
}

For an IEnumerable<T>, compile the result and pass the delegate to Where:

var results = entities.Where(predicate.Compile()).ToArray();

Behavior

  • Add(null) throws ArgumentNullException.
  • With no predicates, Build() returns an expression equivalent to entity => true. This intentionally means "no filter", rather than the mathematical identity of OR (false).
  • With one predicate, Build() preserves its body and parameter.
  • Build() does not clear the builder. Later calls include any subsequently added predicates, without modifying previously built expressions.
  • For IQueryable<T>, translation and evaluation behavior depend on the query provider and the expressions supplied. The builder does not guarantee that every predicate can be translated by every provider.

Trimming and Native AOT

The library supports trimming and Native AOT. Building expressions does not use reflection or generate dynamic code. Expression execution and query translation remain the responsibility of the consuming application or query provider.

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.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

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
1.6.0-rc.1 0 11/17/2026
1.5.0 67 11/10/2026
1.5.0-rc.1 53 11/10/2026

1.5.0
 - Initial release with `OrExpressionBuilder<T>` to combine predicates using short-circuiting logical OR.
 - Preserves nested lambda parameters and returns an always-true predicate when no expressions are added.