SearchLib 1.0.9
dotnet add package SearchLib --version 1.0.9
NuGet\Install-Package SearchLib -Version 1.0.9
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="SearchLib" Version="1.0.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SearchLib" Version="1.0.9" />
<PackageReference Include="SearchLib" />
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 SearchLib --version 1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SearchLib, 1.0.9"
#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 SearchLib@1.0.9
#: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=SearchLib&version=1.0.9
#tool nuget:?package=SearchLib&version=1.0.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SearchLib
SearchLib is a C# library designed to search JSONB data stored in PostgreSQL tables. It allows users to perform dynamic SQL queries on specific JSON keys and values, supporting various data types such as numerical, string, boolean, and arrays. It also enables querying with multiple conditions, making it a flexible solution for working with JSONB data in PostgreSQL.
Features
- Dynamic JSON Key Search: Query JSONB columns for specific keys and values.
- Supports Multiple Data Types: Handles numerical, string, boolean, and array data types.
- Dynamic SQL Query Generation: Automatically generates the correct SQL based on the provided conditions.
- Multiple Conditions: Allows querying multiple JSON keys at once, applying conditions like comparison operators.
Installation
Add the SearchLib class to your project and ensure you have the following dependencies:
- .NET Framework: Ensure your project is using .NET 5 or higher.
- Npgsql: A PostgreSQL data provider for .NET. Install it via NuGet:
dotnet add package Npgsql
## Usage
### 1. Initialize the Library
First, initialize the `SearchLib` class by passing your PostgreSQL connection string:
```csharp
string connectionString = "Host=my_host;Port=5432;Username=my_user;Password=my_pw;Database=my_db";
var searchLib = new SearchLib(connectionString);
### 2. Searching Multiple JSON Keys
To search for multiple conditions on JSON keys, use the `SearchMultipleJsonKeys` method. Pass the table name, column name, and a dynamic array of conditions.
Each condition must contain the `JsonKey`, `ExpectedValue`, and `Operand`.
#### Example:
```csharp
dynamic conditions = new[] {
new { JsonKey = "fps", ExpectedValue = 30, Operand = ">" },
new { JsonKey = "resolution", ExpectedValue = "1080p", Operand = "=" }
};
var multiResults = searchLib.SearchMultipleJsonKeys(
"VideoSourceConfigs", // Table name
"Basic_Params", // Column name storing JSONB data
conditions
);
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net7.0
- Npgsql (>= 7.0.4)
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.0.9 | 4,574 | 10/28/2024 |