Code Monkey home page Code Monkey logo

Comments (6)

cirrusone avatar cirrusone commented on August 16, 2024 1

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.

alirezanet avatar alirezanet commented on August 16, 2024 1

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.

cirrusone avatar cirrusone commented on August 16, 2024 1

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.

alirezanet avatar alirezanet commented on August 16, 2024

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.

alirezanet avatar alirezanet commented on August 16, 2024

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.

alirezanet avatar alirezanet commented on August 16, 2024

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)

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.