UserQueriesSharp 0.2.3

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

UserQueriesSharp

NuGet Version

A powerful search system that allows users to select and order by any property of an IQueryable.

User Queries are designed to work with the Entity Framework system. Just pass in the DbSet as the IQueryable and add the neccessary attributes to the entity class.

See this for a thorough explaination of UserQueries.

Quick Start

  1. Add the NuGet package.
  2. Add the UserQueryable attribute to any property on your class you wish the user to be able to filter / sort by.
  3. Add the PrimaryUserQueryable attribute to your class for the default search property (usually the name or title)
  4. Instantiate a UserQueryProvider or use the extension method EvaluateUserQuery and pass in the user's query string to query the results.

Examples

[PrimaryUserQueryable(nameof(Name))]
class ExampleModel
{
	public int Id { get; set; }

	[UserQueryable("name")]
	public string Name { get; set; } = "";

	[UserQueryable("intval")]
	public int IntValue { get; set; } = 0;

	[UserQueryable("floatval")]
	public float FloatValue { get; set; } = 0.0f;

	[UserQueryable("doubleval")]
	public double DoubleValue { get; set; } = 0.0;

	[UserQueryable("timespanval")]
	public TimeSpan TimeSpanValue { get; set; } = TimeSpan.FromSeconds(1);
}

Jim → returns any entity with the text "Jim" consecutively inside the name property. (case insensitive)

name * "Jim" → returns any entity with the text "Jim" consecutively inside the name property. (case insensitive)

intval < 10 & name = 'fred' → returns any entity with an intvalue less than 10 AND its "name" property is exactly "fred" (case insensitive)

timespanval < '01:00:00' orderby timespanval → returns any entity with a timespanvalue less than an hour, ordered ascending by its timespanvalue.

floatval: -100 - 100 → returns any entity with floatvalue between -100 and 100 inclusive


Example Use Cases

Extension method

Better for one-time situations.

using Microsoft.EntityFrameworkCore;
using UserQueries;

public class Example
{
	DbSet<ExampleModel> dbSet; // get from your dbcontext

	public void MyMethod(string userInput) 
	{
		IQueryable<ExampleModel> result = dbSet.EvaluateUserQuery(userInput);
		foreach(var entity in result) 
		{
			Console.Log(entity.Name);
		}
	}
}
Provider method

Better for situations where queries are called multiple times on one set of data.

using Microsoft.EntityFrameworkCore;
using UserQueries;

public class Example
{
	DbSet<ExampleModel> dbSet; // get from your dbcontext
	UserQueryProvider<ExampleModel> queryProvider;

	public Example() 
	{
		queryProvider = new UserQueryProvider<ExampleModel>(dbSet);
	}

	public void MyMethod(string userInput) 
	{
		foreach(var entity in queryProvider.EvaluateUserQuery(userInput)) 
		{
			Console.Log(entity.Name);
		}
	}
}
Product Compatible and additional computed target framework versions.
.NET 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 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.
  • 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
0.2.3 190 10/6/2025
0.2.2 175 10/6/2025
0.2.1 269 10/6/2025 0.2.1 is deprecated because it has critical bugs.
0.2.0 265 10/6/2025 0.2.0 is deprecated because it has critical bugs.
0.1.0 184 9/29/2025