ReHackt.Linq
7.3.2
See the version list below for details.
dotnet add package ReHackt.Linq --version 7.3.2
NuGet\Install-Package ReHackt.Linq -Version 7.3.2
<PackageReference Include="ReHackt.Linq" Version="7.3.2" />
<PackageVersion Include="ReHackt.Linq" Version="7.3.2" />
<PackageReference Include="ReHackt.Linq" />
paket add ReHackt.Linq --version 7.3.2
#r "nuget: ReHackt.Linq, 7.3.2"
#:package ReHackt.Linq@7.3.2
#addin nuget:?package=ReHackt.Linq&version=7.3.2
#tool nuget:?package=ReHackt.Linq&version=7.3.2
ReHackt.Linq
Some useful System.Linq.IQueryable extensions such as filtering, ordering, paging...
Install
Get it on <a href="https://www.nuget.org/packages/ReHackt.Linq"><img src="https://www.nuget.org/Content/gallery/img/default-package-icon.svg" height=18 style="height:18px;" /> NuGet</a>
QueryableFilter
QueryableFilter<T> allows to dynamically filter an IQueryable<T> with a query string. For example, this can be useful for an API whose clients can filter a collection of entities on any of its properties, or create complex logical queries.
For example
string query = @"Name eq ""Bond"" and (""james"" in Email or (Status in [1, 2] and ""007"" in Codes)) and (Amount lt 1000 or IsEnabled eq false)";
if(QueryableFilter.TryParse(query, out QueryableFilter<Agent> filter) {
IQueryable<Agent> agents = _agentManager.Agents.Filter(filter);
}
else { /* Handle invalid query */ };
Is equivalent to
IQueryable<Agent> agents = _agentManager.Agents
.Where(u => u.Name == "Bond"
&& (u.Email.Contains("james")
|| (new int[] { 1, 2 }.Contains(Status) && u.Codes.Contains("007")))
&& (u.Amount < 1000 || u.IsEnabled == false);
Supported in query
- Boolean operators: and, or, not
- Comparison operators: eq, ne, gt, gte (ge), lt, lte (le), in (
string.ContainsorIList.Contains) - Value types: bool?, DateTimeOffset?, double?, int?, enum, null, string, DateTimeOffset?[], double?[], int?[], string[]
- Parentheses
- Property names (nested properties and collection properties supported)
IQueryable extensions
Filtering
Filter
Filter allows to apply a QueryableFilter<T> to the input sequence using LINQ method syntax.
source.Filter(filter) // filter is a QueryableFilter<T>
Is syntactic sugar for
filter.Apply(source)
This method also allows you to directly filter the input sequence with a query string (implicitly creating a QueryableFilter<T>). Be careful, this can throw an argument exception if the query string is not valid.
source.Filter(filterQuery) // filterQuery is a string
Is syntactic sugar for
QueryableFilter.TryParse(filterQuery, out QueryableFilter<T> filter) ?
source.Filter(filter) :
throw new ArgumentException("Invalid filter query", nameof(filterQuery))
WhereIf
source.WhereIf(condition, predicate)
Is syntactic sugar for
condition ? source.Where(predicate) : source
This allows you to keep the LINQ method syntax to apply filters according to a condition that does not depend on the element being tested.
For example
return source
.Join(...)
.Where(...)
.WhereIf(condition1, predicate1)
.WhereIf(condition2, predicate2)
.OrderBy(...)
.Select(...);
Is equivalent to
source = source
.Join(...)
.Where(...);
if(condition1) {
source = source.Where(predicate1);
}
if(condition2) {
source = source.Where(predicate2);
}
return source
.OrderBy(...)
.Select(...);
Ordering
// TODO Write documentation of Sort(...)
Paging
PageBy
source.PageBy(page, pageSize)
Is syntactic sugar for
source.Skip(((page < 1 ? 1 : page) - 1) * pageSize).Take(pageSize)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. net9.0 was computed. 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 was computed. 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. |
-
net7.0
- ReHackt.Core (>= 7.3.2)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ReHackt.Linq:
| Package | Downloads |
|---|---|
|
ReHackt.AspNetCore.Abstractions
Package Description |
|
|
ReHackt.Linq.AutoMapper
Extends ReHackt.Linq with object-object mapping using AutoMapper profiles. |
|
|
ReHackt.Schema
Package Description |
|
|
ReHackt.Linq.Benchmarks
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 8.0.139 | 620 | 12/16/2025 |
| 8.0.138 | 534 | 11/14/2025 |
| 8.0.137 | 489 | 11/13/2025 |
| 8.0.136 | 502 | 11/12/2025 |
| 8.0.135 | 559 | 10/15/2025 |
| 8.0.134 | 399 | 10/7/2025 |
| 8.0.133 | 466 | 9/10/2025 |
| 8.0.132 | 352 | 9/10/2025 |
| 8.0.131 | 354 | 9/10/2025 |
| 8.0.130 | 374 | 9/10/2025 |
| 8.0.129 | 402 | 9/1/2025 |
| 8.0.128 | 382 | 8/20/2025 |
| 8.0.127 | 388 | 8/18/2025 |
| 8.0.126 | 409 | 8/15/2025 |
| 8.0.125 | 337 | 8/15/2025 |
| 8.0.124 | 382 | 8/14/2025 |
| 8.0.123 | 377 | 8/14/2025 |
| 8.0.122 | 368 | 8/14/2025 |
| 8.0.121 | 371 | 8/13/2025 |
| 7.3.2 | 1,319 | 4/27/2023 |