Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Index was outside the bounds of the array #45

Closed
cirrusone opened this issue Nov 20, 2021 · 1 comment · Fixed by #46
Closed

Index was outside the bounds of the array #45

cirrusone opened this issue Nov 20, 2021 · 1 comment · Fixed by #46
Assignees
Labels
bug Something isn't working close fixed

Comments

@cirrusone
Copy link

Describe the bug
This bug seems to fixed for List but I get errors with arrays, System.IndexOutOfRangeException: 'Index was outside the bounds of the array.' on line var expression = gridifyQuery.GetFilteringExpression(gridifyMapper).Compile();

To Reproduce

using Gridify;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    public static class Program
    {
        public static void Main(string[] args)
        {
            var test = new Test();
            test.Run();
        }
    }

    public class Test
    {
        public void Run()
        {
            List<Level1> level1List = new List<Level1>();
            level1List.Add(new Level1());

            var gridifyMapper = new GridifyMapper<Level1>().GenerateMappings()
                .AddMap("level4_property1", (q, index) => q.Level2List.Select(x => x.Level3.Level4List[index].Property1));

            var gridifyQuery = new GridifyQuery() { Filter = "level4_property1[0] > 5" };
            var expression = gridifyQuery.GetFilteringExpression(gridifyMapper).Compile();

            var query = level1List.Where(expression);
        }
    }

    public class Level1
    {
        public string Name { get; set; }
        public Level2[] Level2List = new Level2[]
        {
            new Level2()
            {
                Name = "1",
                Level3 = new Level3()
                {
                    Name = "2",
                    Level4List = new List<Level4>()
                    {
                        new Level4() {Name = "3", Property1 = 3, Property2 = 4},
                        new Level4() {Name = "4", Property1 = 4, Property2 = 5},
                        new Level4() {Name = "5", Property1 = 5, Property2 = 6}
                    }
                }
            },

            new Level2()
            {
                Name = "6",
                Level3 = new Level3()
                {
                    Name = "7",
                    Level4List = new List<Level4>()
                    {
                        new Level4() {Name = "8", Property1 = 8, Property2 = 9},
                        new Level4() {Name = "9", Property1 = 9, Property2 = 10},
                        new Level4() {Name = "10", Property1 = 10, Property2 = 11}
                    }
                }
            },

        };
    }

    public class Level2
    {
        public string Name { get; set; }
        public Level3 Level3 = new Level3();
    }

    public class Level3
    {
        public string Name { get; set; }
        public List<Level4> Level4List = new List<Level4>();
    }

    public class Level4
    {
        public string Name { get; set; }
        public double Property1 { get; set; }
        public double Property2 { get; set; }
    }
}

@alirezanet alirezanet self-assigned this Nov 20, 2021
@alirezanet alirezanet added the bug Something isn't working label Nov 20, 2021
alirezanet added a commit that referenced this issue Nov 20, 2021
alirezanet added a commit that referenced this issue Nov 20, 2021
* Fix BuildCompiledEvaluator performance issue

* add QueryBuilderEvaluatorBenchmark and last run result

* fix ElementType error, issue #45

* update to v2.4.4
@alirezanet alirezanet mentioned this issue Nov 20, 2021
@alirezanet
Copy link
Owner

fixed in v2.4.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working close fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants