Introduction

Gridify is a dynamic LINQ library that simplifies the process of converting strings to LINQ queries. With exceptional performance and ease-of-use, Gridify makes it effortless to apply filtering, sorting, and pagination using text-based data.

Gridify.Elasticsearch is an extension of Gridify, that provides an ability to generate Elasticsearch DSL queries. Read more about Gridify.Elasticsearch in a separate thread of the documentation.

Features

  • Fast and easy to use
  • Supports filtering, sorting, and pagination
  • Supports string to LINQ conversion
  • Supports nested queries and sub-collections
  • Supports string to object mapping
  • Supports query compilation
  • Supports collection indexes
  • Custom Operators
  • Compatible with ORMs, especially Entity Framework
  • Can be used on every collection that LINQ supports
  • Compatible with object-mappers like AutoMapper

Examples

To better illustrate how Gridify works, we've prepared a few examples:

Performance

Filtering is the most expensive feature in Gridify. The following benchmark compares filtering in various popular dynamic LINQ libraries. Interestingly, Gridify outperforms even Native LINQ in terms of speed. It's worth mentioning that other features like Pagination and Sorting in Gridify have minimal impact on performance.

MethodMeanErrorStdDevRatioAllocatedAlloc Ratio
Gridify599.8 us2.76 us2.45 us0.9236.36 KB1.11
Native_LINQ649.9 us2.55 us2.38 us1.0032.74 KB1.00
DynamicLinq734.8 us13.90 us13.01 us1.13119.4 KB3.65
Sieve1,190.9 us7.41 us6.93 us1.8353.05 KB1.62
Fop2,637.6 us8.59 us7.61 us4.06321.57 KB9.82
CSharp_Scripting216,863.8 us4,295.66 us6,021.92 us336.6423660.26 KB722.71

BenchmarkDotNet v0.13.10, Windows 11 (10.0.22621.2715/22H2/2022Update/SunValley2) 12th Gen Intel Core i7-12800H, 1 CPU, 20 logical and 14 physical cores .NET SDK 8.0.100 [Host] : .NET 8.0.0 (8.0.23.53103), X64 RyuJIT AVX2

This Benchmark is available Hereopen in new window