Comments (6)
My example only added a single Level1 item but I can see scenarios where I might want to filter a base single object with nested collections and also a base collection with nested collections.
Thanks for looking into this as it will make it an even more powerful library.
Another thing I thought about which may improve performance would it be possible to add options to pre-compile the filter expressions eg Expression.Compile Method
from gridify.
This feature is available in 2.0.0-beta.1
.
It would be awesome if I have your feedback.
usage:
var gm = new GridifyMapper<Level1>()
.GenerateMappings()
.AddMap("prop1", l1 => l1.Level2List.SelectMany(l2 => l2.Level3List).Select(l3 => l3.Property1));
from gridify.
Thanks for such a fast update. For simple logic this works brilliantly.
After testing I do have a few scenarios where this could be improved further but not sure how complex this is?
Say I wanted to filter to find where BOTH Level2List_Id=101
and that same item has Level2List_Level3List_Property1>=3.0
the filter Filter = "Level2List_Id=101, Level2List_Level3List_Property1>=3.0"
doesn't work as the AND is finding two separate instances of Level2.
Is there a way to introduce chained logic so that there can be sub filters?
Eg something like Filter = "Level2List_Id=101 => Level3List_Property1>=3.0"
Ie are there any records with Level2.Id==101 and that same item also has Level3List_Property1>=3.0?
The example below returns 1 item as both conditions are met but in the above example it should return zero items as there is no data with Level2.Id == 101 and also the Level3 Property1 >= 3.0.
static void Main(string[] args)
{
Level1 level1 = new Level1()
{
Id = 1,
Name = "Level1Name",
Level2List = new List<Level2>()
{
new Level2() { Id = 101, Name = "Level2_1", Level3List = new List<Level3>() { new Level3() { Property1 = 2.0, Property2 = 100.0, Level = 0 } } },
new Level2() { Id = 102, Name = "Level2_2", Level3List = new List<Level3>() { new Level3() { Property1 = 3.0, Property2 = 200.0, Level = 1 } } },
new Level2() { Id = 103, Name = "Level2_3", Level3List = new List<Level3>() { new Level3() { Property1 = 4.0, Property2 = 300.0, Level = 2 } } }
}
};
Level1[] array = new Level1[1];
array[0] = level1;
var ds = array.AsQueryable();
// Multi Nested Property
var gq2 = new GridifyQuery { Filter = "Level2List_Id=101, Level2List_Level3List_Property1>=3.0" };
var gm2 = new GridifyMapper<Level1>()
.GenerateMappings()
.AddMap("Level2List_Level3List_Property1", l1 => l1.Level2List.SelectMany(l2 => l2.Level3List).Select(l3 => l3.Property1))
.AddMap("Level2List_Id", l1 => l1.Level2List.Select(l3 => l3.Id));
var actual2 = ds.AsQueryable()
.ApplyFiltering(gq2, gm2)
.ToList();
}
from gridify.
I would still want to return items of type Level1 but filter on properties of Level3.
Hi, In your example filtering on the nested collections doesn't make sense because you have only one Level1 item in your collection (ds) so you can not filter anything here. but I am trying to add a feature to support these kinds of scenarios that you have multiple Level1 items in your initial DS.
I'm planning to release this feature in the next version2 alpha version.
thank you for the feedback
from gridify.
My example only added a single Level1 item but I can see scenarios where I might want to filter a base single object with nested collections and also a base collection with nested collections.
Thanks for looking into this as it will make it an even more powerful library.
Yes, you are right. your welcome.
Another thing I thought about which may improve performance would it be possible to add options to pre-compile the filter expressions eg Expression.Compile Method
I think we should discuss this in another issue because gridify usually been used alongside an ORM like EF so gridify doesn't even use the expression and compiled expressions can not be used in the EF but in other cases (without any ORMs) maybe this feature can be useful. (I need to do some research about this)
from gridify.
hmm, Interesting you are absolutely right. I'm thinking about using parenthesis to separate chain filtering from normal filtering. something like (Level2List_Id=101, Level2List_Level3List_Property1>=3.0) , Id < 10
.
I'll look into this for the next beta version. probably 2.0.0-beta-3
please open a separate issue for this if you had time. thank you for the feedback
from gridify.
Related Issues (20)
- DateTime Kind and PostgreSQL HOT 13
- IN style operator HOT 5
- Support for. NET8 HOT 4
- NativeAOT support
- Why library can not resolve IGridifyMapper<T> default in DbContext.ServiceProvider if exists HOT 1
- GRPC Support HOT 2
- Comparing data between two fields rather than using hardcoded values
- Cleanup dependencies HOT 2
- Filtering based on IDictionary values
- Passing filter value on CustomOperator Expression creation - for ContainsAny operator HOT 10
- Support automatic mapping generation for list of primitives
- Filtering for null/empty case insensitive HOT 3
- EntityFramework filtering with Many to Many case
- Concurrently changing GridifyGlobalConfigurations causes inconsistent behavior
- Add support generating conditions with Index or Key in gridify-client
- DateTime Kind and Postgres HOT 4
- Global configuration for case insensitive string search
- QueryBuilder build into a GridifyQuery HOT 2
- Case in-sensitive filtering for List<string> does not work HOT 2
- Generate mapping with maxDepth = 2 and a nested list class causing ArgumentException
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gridify.