Giter Club home page Giter Club logo

dynamicfilter.sql's Introduction

DynamicFilter.Sql

GitHub GitHub Workflow Status Nuget

A Fast and efficient dotnet library to dynamically generate compiled lambda expressions from sql style filters.

Installation

DynamicFilter.Sql package can be install via Nuget

dotnet add package DynamicFilter.Sql

Usage/Examples

The Compile function takes a generic parameter that is used to determine the entity fields. This could be a user defined class or it could be a Dictionary<string, object> type.

User defined class

With a user defined class, the field names within the filter expression have to match the property names defined within the class. This is resolved at compile time.

var myfilter = FilterExpression.Compile<User>("(Age > 10) and (Name like 'Alice%' or Name like 'Bob%')");

//Evaluate a single object
bool match = myFilter(new User {Age = 15, Name="Alice Wonderland"})

//Filter a collection
var names = users.Where(myfilter).Select(u => u.Name);

Dictionary

var dict = new Dictionary<string, object> {
                {"Name" , "Alice"},
                {"Age" , 12},
            };

var filter = FilterExpression.Compile<Dictionary<string, object>>("(Age > 10) and (Name like 'Alice%' or Name like 'Bob%')");

var match = filter(dict); //returns true

Features

  • Compile to .NET IL code.
  • Support Sql Comparison operations
    • =, <, >, <=, >=
    • like, not like
    • in, not in
    • is null, is not null
  • Dictionary and User objects

Use cases

  • Dynamically generate code to filter objects in memory
  • Filter a stream of data with a multiple criteria
  • User Preferences/Filters that could be potentially saved/loaded from a File/Database.

Authors

dynamicfilter.sql's People

Contributors

prakashrx avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.