Skip to content

Implementation of the Filtering API of Microsoft Guidelines REST API using @SuperPower library.

License

Notifications You must be signed in to change notification settings

sleemer/Guidelines.RestApi.Collections.Filtering

Repository files navigation

Guidelines.RestApi.Collections.Filtering

Implementation of the Filtering API of Microsoft Guidelines REST API using Superpower.

Supported comparison operators

  • Equal
var expression = "Id eq 1";
  • NotEqual
var expression = "Id ne 1";
  • GraterThan
var expression = "Id gt 1";
  • GraterThanOrEqual
var expression = "Id ge 1";
  • LessThan
var expression = "Id lt 1";
  • LessThanOrEqual
var expression = "Id le 1";
  • In
var expression = "Id in (1,2,3)";

Supported string functions

  • Length
var expression = "length(Title) gt 1";
  • StartsWith
var expression = "startswith(Title, 'Some')";
  • EndsWith
var expression = "endswith(Title, 'Title')";
  • Contains
var expression = "contains(Title, 'Title')";
  • IndexOf
var expression = "indexof(Title, 'Title') eq 0";

Supported logical operators

  • And
var expression = "Id eq 1 and Value ne 5.0";
  • Or
var expression = "Id eq 1 or Value ne 5.0";
  • Not
var expression = "not Id eq 1";

Usage

var expression = "(length(Title) gt 5 and contains(Title, 'tle')) or Id in (3,5)";
// Parse a filtering function
Expression<Func<Item, bool>> predicateExpression = FilterParser.Parse<Item>(expression);
// Compile a filtering function
Func<Item, bool> predicate = FilterCompiler.Compile<Item>(expression);

About

Implementation of the Filtering API of Microsoft Guidelines REST API using @SuperPower library.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages