Skip to content

FirstOrDefault() method doesn't work when database splitting is used #136

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

Closed
AlexandrSHad opened this issue Aug 12, 2021 · 0 comments
Closed
Labels
bug Something isn't working done

Comments

@AlexandrSHad
Copy link
Contributor

Looks like FirstOrDefault() method doesn't work in combination with a discriminator.
To reproduce this you can add the following tests to the file:

        [Fact]
        public void Discriminator_FirstOrDefault()
        {
            var json1 = _rebels.FirstOrDefault().ToString();
            var json2 = _simpleRebels.FirstOrDefault().ToString();
            Assert.Equal(@"{""limit"":1, ""selector"":{""split_discriminator"":""Rebel""}}", json1);
            Assert.Equal(@"{""limit"":1, ""selector"":{""split_discriminator"":""SimpleRebel""}}", json2);
        }

        [Fact]
        public void Discriminator_FirstOrDefault_WithExpression()
        {
            var json1 = _rebels.FirstOrDefault(c => c.Age == 19).ToString();
            var json2 = _simpleRebels.FirstOrDefault(c => c.Age == 19).ToString();
            Assert.Equal(@"{""limit"":1, ""selector"":{""$and"":[{""age"":19},{""split_discriminator"":""Rebel""}]}}", json1);
            Assert.Equal(@"{""limit"":1, ""selector"":{""$and"":[{""age"":19},{""split_discriminator"":""SimpleRebel""}]}}", json2);
        }

Exception "System.IndexOutOfRangeException : Index was outside the bounds of the array." will be thrown.

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

No branches or pull requests

2 participants