SearchBuilder 1.0.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package SearchBuilder --version 1.0.0
NuGet\Install-Package SearchBuilder -Version 1.0.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="SearchBuilder" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SearchBuilder" Version="1.0.0" />
<PackageReference Include="SearchBuilder" />
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 SearchBuilder --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SearchBuilder, 1.0.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 SearchBuilder@1.0.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=SearchBuilder&version=1.0.0
#tool nuget:?package=SearchBuilder&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Search Builder — User Guide
1. Introduction
Search Builder
helps create dynamic filtering conditions for LINQ through a class that defines searchable fields.
You only need to declare properties and decorate them with [FieldMap]
specifying:
- Column name(s) in the database.
- Condition type (
KindField
). - Comparison operator (
Operation
).
The system will automatically generate an expression (Expression
) to pass into .Where(...)
when querying with EF Core.
2. Defining the Search Class
Example: SearchNhapKho
public class SearchNhapKho
{
[FieldMap("Ma,Kho.Ten", KindField.Search, Operation.Contains)]
public string? KeySearch { get; set; }
[FieldMap("Kho.Ten", KindField.Search, Operation.Contains)]
public string? TuKhoa { get; set; }
[FieldMap("Ma", KindField.Filter, Operation.EqualTo)]
public string? Ma { get; set; }
[FieldMap("Id", KindField.Filter, Operation.EqualTo)]
public int? Id { get; set; }
[FieldMap("SoLuong", KindField.Filter, Operation.GreaterThan)]
public int? SoLuongMin { get; set; }
[FieldMap("SoLuong", KindField.Filter, Operation.LessThan)]
public int? SoLuongMax { get; set; }
[FieldMap("NgayNhap", KindField.Filter, Operation.Between)]
public Range<DateTime?>? NgayNhapTuDen { get; set; }
[FieldMap("TrangThai", KindField.Filter, Operation.In)]
public List<int>? TrangThaiList { get; set; }
}
3. Usage in the Search Method
var predicate = DynamicSearch.Build\<NhapKho, SearchNhapKho>(search);
var result = \_context.NhapKhos
.Include(x => x.Kho)
.Where(predicate)
.ToList();
4. Sample JSON Request
{
"keySearch": "string",
"tuKhoa": "string",
"ma": "string",
"id": 0,
"soLuongMin": 0,
"soLuongMax": 0,
"ngayNhapTuDen": {
"from": "2025-08-13T12:13:16.065Z",
"to": "2025-08-13T12:13:16.065Z"
},
"trangThaiList": [0]
}
💡 Notes
KindField.Search
→ Conditions are joined using OR.KindField.Filter
→ Conditions are joined using AND.Operation
→ Defines the comparison logic.
5. Reference
5.1. Range<T>
Property | Description |
---|---|
From |
Start value |
To |
End value |
5.2. KindField
— Relation Between Conditions
Value | LINQ Relation |
---|---|
Search |
OR |
Filter |
AND |
5.3. Operation
— Supported Comparison Operators
Name | Description | Notes |
---|---|---|
Contains |
Similar to .Contains() in LINQ |
|
EqualTo |
Equivalent to == |
|
StartsWith |
Similar to .StartsWith() |
|
EndsWith |
Similar to .EndsWith() |
|
GreaterThan |
> |
|
LessThan |
< |
|
GreaterThanOrEqual |
>= |
|
LessThanOrEqual |
<= |
|
In |
Value exists in list | Type must be List<T> |
Between |
Value is within range | Type must be Range<T> |
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 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.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.