MatinDeWet.Searchable.SqlServer 1.0.1

dotnet add package MatinDeWet.Searchable.SqlServer --version 1.0.1
                    
NuGet\Install-Package MatinDeWet.Searchable.SqlServer -Version 1.0.1
                    
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="MatinDeWet.Searchable.SqlServer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MatinDeWet.Searchable.SqlServer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="MatinDeWet.Searchable.SqlServer" />
                    
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 MatinDeWet.Searchable.SqlServer --version 1.0.1
                    
#r "nuget: MatinDeWet.Searchable.SqlServer, 1.0.1"
                    
#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 MatinDeWet.Searchable.SqlServer@1.0.1
                    
#: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=MatinDeWet.Searchable.SqlServer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=MatinDeWet.Searchable.SqlServer&version=1.0.1
                    
Install as a Cake Tool

Searchable.SqlServer

NuGet Version CI Status Publish Status

SQL Server-specific dynamic search helpers for Entity Framework Core.

This package provides a small, focused API for building LIKE-based search filters over IQueryable<T> using SQL Server semantics. It is intended to be consumed as a NuGet package and versioned like one.

Package

dotnet add package MatinDeWet.Searchable.SqlServer

What It Does

  • Builds dynamic search expressions from a request object or raw search terms.
  • Supports Contains, StartsWith, EndsWith, and Exact matching modes.
  • Escapes SQL Server wildcard characters before composing the query.
  • Lets you combine multiple properties and multiple search terms with AND / OR logic.
  • Keeps the API small so it can stay provider-specific and easy to mirror later for PostgreSQL.

Usages

1. Request-based search over a queryable

Use this when your request object already carries a search term.

using Searchable.SqlServer;
using Searchable.SqlServer.Contracts;
using Searchable.SqlServer.Enums;

IQueryable<Person> query = dbContext.People;
ISearchableRequest request = new SearchableRequest("al ex");

query = query.DynamicLikeSearch(
    request,
    [person => person.FirstName, person => person.LastName],
    ILikeMatchModeEnum.Contains);

DynamicLikeSearch removes empty input handling from the calling code and returns the original query when the request or search term is blank.

2. Search a queryable with raw terms

Use this when you already have a collection of terms and do not want to wrap them in a request object.

ICollection<string> terms = ["al", "ex"];

query = query.DynamicLikeSearch(
    terms,
    [person => person.FirstName, person => person.LastName],
    ILikeMatchModeEnum.StartsWith,
    termLogic: true,
    propertyLogic: true);

In this example, both terms must match because termLogic: true uses AND, while either property may match because propertyLogic: true uses OR.

3. Build a reusable expression from a request

Use this when you want to build an Expression<Func<T, bool>> and pass it into a LINQ Where later.

Expression<Func<Person, bool>> predicate = SearchableExtensions.BuildDynamicSearchExpression<Person>(
    request,
    [person => person.FirstName, person => person.LastName],
    ILikeMatchModeEnum.Contains);

query = query.Where(predicate);

4. Build a reusable expression from raw terms

Use this when the search terms are already in memory and you want to compose a predicate first.

Expression<Func<Person, bool>> predicate = SearchableExtensions.BuildDynamicSearchExpression<Person>(
    ["al", "ex"],
    [person => person.FirstName, person => person.LastName],
    ILikeMatchModeEnum.Contains,
    termLogic: false,
    propertyLogic: true);

query = query.Where(predicate);

5. Match modes

ILikeMatchModeEnum controls the generated SQL Server LIKE pattern.

  • Contains matches anywhere in the string.
  • StartsWith matches values that begin with the term.
  • EndsWith matches values that end with the term.
  • Exact matches the value exactly.

6. Search term normalization

Search terms are trimmed, split on whitespace, and escaped before being used in the query. That means input like " al ex " becomes two search terms, and special SQL Server wildcard characters are safely escaped.

API Surface

  • Searchable.SqlServer.SearchableExtensions
  • Searchable.SqlServer.Contracts.ISearchableRequest
  • Searchable.SqlServer.Enums.ILikeMatchModeEnum

The package uses the GPL-3.0-only license.

Product Compatible and additional computed target framework versions.
.NET 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.

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.1 98 6/13/2026
1.0.0 94 6/9/2026