Description
Runtime parser for string expressions (formulas, conditions, method calls, properties/arrays). Builds dynamic LINQ expression tree at runtime and compiles it to the lambda delegate that can be evaluated. Supports variables.
NReco LambdaParser alternatives and similar packages
Based on the "Database" category.
Alternatively, view NReco LambdaParser alternatives based on common mentions on social networks and blogs.
-
LiteDB
LiteDB - A .NET NoSQL Document Store in a single data file -
Event Store
The stream database optimised for event sourcing -
SqlKata Query Builder
SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird -
Marten
.NET Transactional Document DB and Event Store on PostgreSQL -
Realm Xamarin
Realm is a mobile database: a replacement for SQLite & ORMs -
BrightstarDb
This is the core development repository for BrightstarDB. -
DBreeze
C# .NET MONO NOSQL ( key value store embedded ) ACID multi-paradigm database management system. -
ZoneTree
ZoneTree is a persistent, high-performance, transactional, ACID-compliant ordered key-value database for NET. It can operate in memory or on local/cloud storage. -
StringDB
StringDB is a modular, key/value pair archival DB designed to consume *tiny* amounts of ram & produce *tiny* databases. -
Db4o-gpl
new Db4o GPL Source Code for Java7+ & .netstardard2.0 Android Xamarin..., the best database project to help you to learn how to make databases -
Mailcloud.Hydra
A set of components to take the most advantage of performance and capacity of Azure Storage.
Static code analysis for 29 languages.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of NReco LambdaParser or a related project?
README
NReco LambdaParser
Runtime parser for string expressions (formulas, method calls, properties/fields/arrays accessors). LambdaParser
builds dynamic LINQ expression tree and compiles it to the lambda delegate. Types are resolved at run-time like in dynamic languages.
- PCL (Portable) library: can be used with any .NET target: net40+sl5, net45+wp8+win8+wpa81, .NET Standards 1.3 (.NET Core apps)
- any number of variables (values can be provided as dictionary or by callback delegate)
- supports arithmetic operations (+, -, *, /, %), comparisons (==, !=, >, <, >=, <=), conditionals including (ternary) operator ( ? : )
- access object properties, call methods and indexers, invoke delegates
- dynamic typed variables: performs automatic type conversions to match method signature or arithmetic operations
- create arrays and dictionaries with simplified syntax:
new dictionary{ {"a", 1}, {"b", 2} }
,new []{ 1, 2, 3}
Nuget package: NReco.LambdaParser
var lambdaParser = new NReco.Linq.LambdaParser();
var varContext = new Dictionary<string,object>();
varContext["pi"] = 3.14M;
varContext["one"] = 1M;
varContext["two"] = 2M;
varContext["test"] = "test";
Console.WriteLine( lambdaParser.Eval("pi>one && 0<one ? (1+8)/3+1*two : 0", varContext) ); // --> 5
Console.WriteLine( lambdaParser.Eval("test.ToUpper()", varContext) ); // --> TEST
(see unit tests for more expression examples)
Custom values comparison
By default LambdaParser
uses ValueComparer
for values comparison. You can provide your own implementation or configure its option to get desired behaviour:
ValueComparer.NullComparison
determines how comparison withnull
is handled. 2 options:MinValue
: null is treated as minimal possible value for any type - like .NET IComparerSql
: null is not comparable with any type, including another null - like in SQL
ValueComparer.SuppressErrors
allows to avoid convert exception. If error appears during comparison exception is not thrown and this means that values are not comparable (= any condition leads tofalse
).var valComparer = new ValueComparer() { NullComparison = ValueComparer.NullComparisonMode.Sql }; var lambdaParser = new LambdaParser(valComparer);
Who is using this?
NReco.LambdaParser is in production use at SeekTable.com and PivotData microservice (used for user-defined calculated cube members: formulas, custom formatting).
License
Copyright 2016-2020 Vitaliy Fedorchenko
Distributed under the MIT license
*Note that all licence references and agreements mentioned in the NReco LambdaParser README section above
are relevant to that project's source code only.