PosInformatique.Foundations.Linq.Expressions
1.5.0
Prefix Reserved
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
<PackageReference Include="PosInformatique.Foundations.Linq.Expressions" Version="1.5.0" />
<PackageVersion Include="PosInformatique.Foundations.Linq.Expressions" Version="1.5.0" />
<PackageReference Include="PosInformatique.Foundations.Linq.Expressions" />
paket add PosInformatique.Foundations.Linq.Expressions --version 1.5.0
#r "nuget: PosInformatique.Foundations.Linq.Expressions, 1.5.0"
#:package PosInformatique.Foundations.Linq.Expressions@1.5.0
#addin nuget:?package=PosInformatique.Foundations.Linq.Expressions&version=1.5.0
#tool nuget:?package=PosInformatique.Foundations.Linq.Expressions&version=1.5.0
PosInformatique.Foundations.Linq.Expressions
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.Invokeor 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)throwsArgumentNullException.- With no predicates,
Build()returns an expression equivalent toentity => 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.
Links
| Product | Versions 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. |
-
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.