https://github.com/oldrev/jasper
A Lisp S-Expression style JSON predicate parser for Linq.
https://github.com/oldrev/jasper
Last synced: over 1 year ago
JSON representation
A Lisp S-Expression style JSON predicate parser for Linq.
- Host: GitHub
- URL: https://github.com/oldrev/jasper
- Owner: oldrev
- Created: 2022-05-22T09:32:45.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-29T04:02:18.000Z (over 3 years ago)
- Last Synced: 2025-01-22T10:47:22.093Z (over 1 year ago)
- Language: C#
- Size: 32.2 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Sandwych.Jasper
A Lisp S-Expression style JSON predicate parser for LINQ.
It works on all LINQ implementation, including:
* LINQ to Objects
* LINQ to XML
* LINQ to DB
* NHibernate
* EntityFramework Core
* etc...
# Usage
```csharp
record class Employee(string Name, int Age);
var employees = new Employee[] {
new Employee("Alice", 40),
new Employee("Bob", 41),
new Employee("Charlie", 42),
new Employee("Ethan", 60),
};
var json = """
[
"and",
[">=", "Age", 35],
["or", ["=", "Name", "Alice"], [">", "Age", 45]]
]
""";
var filteredEmployees = employees.AsQueryable().WhereByJson(json);
// Equals to LINQ lambda:
// employees.AsQueryable().Where(x => x.Age >= 35 && (x.Name == "Alice" || x.Age > 45))
```
See the demostration project `Sandwych.Jasper.Demo` for details.
# Status
PreAlpha, working in progress.