You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a way to introduce chained logic so that there can be sub filters? For example based on the sample code below the filter Filter = "Level2List_Id=101, Level2List_Level3List_Property1>=3.0" might not do what is expected.
It currently finds Level2 items with Id=101 and Level3 items with Property1>=3.0 - but they do not have to be the same item.
Sometimes we need to chain filters so they apply to a single item, eg filter where Level2 item is BOTH Id=101 and also has Level3 items with Property1>=3.0.
For example, something like this
AND: (Level2List_Id=101, Level2List_Level3List_Property1>=3.0) , Id < 10
OR: (Level2List_Id=101| Level2List_Level3List_Property1>=3.0) , Id < 10
The example below returns 1 item as both conditions are met but with chained logic should return zero items as there is no data with Level2.Id == 101 and also 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();
}
It may be required to actually specify what property (object or collection) is passed in the chain for sub-filtering.
The text was updated successfully, but these errors were encountered:
Hi, this feature is available in version 2.0.0-beta.3.
If you use parenthesis around any nested collection that has the same type(like the above example), Gridify doesn't create separated queries.
I've tested many scenarios like this and it's working fine, but because of the massive complexity of this feature, you might find some use-cases that I did not cover yet.
I appreciate any feedback again.
thank you for your contribution.
Is there a way to introduce chained logic so that there can be sub filters? For example based on the sample code below the filter
Filter = "Level2List_Id=101, Level2List_Level3List_Property1>=3.0"
might not do what is expected.It currently finds Level2 items with Id=101 and Level3 items with Property1>=3.0 - but they do not have to be the same item.
Sometimes we need to chain filters so they apply to a single item, eg filter where Level2 item is BOTH Id=101 and also has Level3 items with Property1>=3.0.
For example, something like this
AND:
(Level2List_Id=101, Level2List_Level3List_Property1>=3.0) , Id < 10
OR:
(Level2List_Id=101| Level2List_Level3List_Property1>=3.0) , Id < 10
The example below returns 1 item as both conditions are met but with chained logic should return zero items as there is no data with Level2.Id == 101 and also Level3 Property1 >= 3.0.
It may be required to actually specify what property (object or collection) is passed in the chain for sub-filtering.
The text was updated successfully, but these errors were encountered: