Quaero 0.1.0

dotnet add package Quaero --version 0.1.0                
NuGet\Install-Package Quaero -Version 0.1.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="Quaero" Version="0.1.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Quaero --version 0.1.0                
#r "nuget: Quaero, 0.1.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.
// Install Quaero as a Cake Addin
#addin nuget:?package=Quaero&version=0.1.0

// Install Quaero as a Cake Tool
#tool nuget:?package=Quaero&version=0.1.0                

Quaero

A small query language that can transform queries into system-specific filters.

Quaero is designed to be web-friendly by using letter-based operators instead of symbols. It's very similar to Microsoft Graph (OData) filters, with a few minor differences:

  1. Infix not operators
  2. Infix function operators

See example queries for some examples.

This repository contains translation implementations for Microsoft Graph and Active Directory (LDAP) filters, as well as in-memory predicates.

Supported operators

The language supports a wide range of operators supported by most filter/query languages.

Equality operators

  • Equals (eq)
  • Not equals (ne)
  • Logical negation (not)
  • In (in)

Relational operators

  • Less than (lt)
  • Greater than (gt)
  • Less than or equal to (le)
  • Greater than or equal to (ge)

Conditional operators

  • And (and)
  • Or (or)

Functions

  • Starts with (startsWith)
  • Ends with (endsWith)

Example queries

Quaero Microsoft Graph LDAP
age gt 42 age gt 42 (age>=43)
age ge 42 age ge 42 (age>=42)
age lt 42 age lt 42 (age<=41)
age le 42 age le 42 (age<=42)
name eq 'John' name eq 'John' (name=John)
name not eq 'John' not(name eq 'John')' (!(name=John))
department in ('Retail', 'Sales') department in ('Retail', 'Sales') (\|(department=Retail)(department=Sales))
isRead eq false isRead eq false (isRead=FALSE)
mail endsWith 'outlook.com' endsWith(mail, 'outlook.com') (mail=*outlook.com)
parent ne null parent ne null (parent=*)
id eq '275e50ae-ceb8-4f33-9e68-b3b9dc87ea68' id eq '275e50ae-ceb8-4f33-9e68-b3b9dc87ea68' (id=\AE\50\5E\27\B8\CE\33\4F\9E\68\B3\B9\DC\87\EA\68)

Usage

Either parse a filter expression from a string using Filter.Parse or Filter.TryParse:

Filter filter = Filter.Parse("age gt 42");

Or manually construct a filter expression using the factory methods on the Filter class:

Filter filter = Filter.GreaterThan("age", 42);

Once the filter has been successfully parsed, it can be optimized by calling the Optimize extension method. This will take care of removing redundancies and shortening the resulting query.

To transform the query into an LDAP filter, reference the Quaero.Ldap package and call the ToLdapFilter method on it:

string result = filter.ToLdapFilter();

For Microsoft Graph, reference the Quaero.MicrosoftGraph package and call ToMicrosoftGraphFilter on the filter:

string result = filter.ToMicrosoftGraphFilter();

If you want to evaluate a filter in-memory, you can call the ToPredicate<T> method on it:

record Person(string Name, int Age);
Func<Person, bool> predicate = filter.ToPredicate<Person>();
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Quaero:

Package Downloads
Quaero.MicrosoftGraph

Package Description

Quaero.Ldap

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.1.0 331 11/2/2023