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

[BUG] Get items by ids from ICollection failed #1695

Closed
mikhail-khalizev opened this issue May 24, 2020 · 1 comment
Closed

[BUG] Get items by ids from ICollection failed #1695

mikhail-khalizev opened this issue May 24, 2020 · 1 comment
Labels

Comments

@mikhail-khalizev
Copy link

Version
5.0.8

Describe the bug
Get items by ids from ICollection throw exception:
System.ArgumentOutOfRangeException : Specified argument was out of the range of valid values. (Parameter 'index')

Code to Reproduce

public class StateModel
{
    [BsonId]
    public ObjectId Id { get; set; }
}

[Fact]
public void MyTest()
{
    using var db = new LiteDatabase(":memory:");
    var col = db.GetCollection<StateModel>("col");

    ICollection<ObjectId> ids = new List<ObjectId>();
    for (var i = 1; i <= 10; i++)
        ids.Add(col.Insert(new StateModel()));

    var items = col.Query()
        .Where(x => ids.Contains(x.Id))
        .ToList();

    items.Should().HaveCount(10);
}

Expected behavior
No exception throw. Test passed.

Screenshots/Stacktrace


System.ArgumentOutOfRangeException : Specified argument was out of the range of valid values. (Parameter 'index')
   at System.Linq.Expressions.InstanceMethodCallExpression1.GetArgument(Int32 index)
   at System.Dynamic.Utils.ListArgumentProvider.GetElement(Int32 index)
   at System.Dynamic.Utils.ListProvider`1.get_Item(Int32 index)
   at System.Collections.ObjectModel.ReadOnlyCollection`1.System.Collections.Generic.IList<T>.get_Item(Int32 index)
   at LiteDB.LinqExpressionVisitor.ResolvePattern(String pattern, Expression obj, IList`1 args) in C:\Users\micky\Documents\Source\LiteDB\LiteDB\Client\Mapper\Linq\LinqExpressionVisitor.cs:line 511
   at LiteDB.LinqExpressionVisitor.VisitMethodCall(MethodCallExpression node) in C:\Users\micky\Documents\Source\LiteDB\LiteDB\Client\Mapper\Linq\LinqExpressionVisitor.cs:line 213
   at System.Linq.Expressions.MethodCallExpression.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression`1 node)
   at LiteDB.LinqExpressionVisitor.VisitLambda[T](Expression`1 node) in C:\Users\micky\Documents\Source\LiteDB\LiteDB\Client\Mapper\Linq\LinqExpressionVisitor.cs:line 95
   at System.Linq.Expressions.Expression`1.Accept(ExpressionVisitor visitor)
   at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
   at LiteDB.LinqExpressionVisitor.Resolve(Boolean predicate) in C:\Users\micky\Documents\Source\LiteDB\LiteDB\Client\Mapper\Linq\LinqExpressionVisitor.cs:line 64
   at LiteDB.BsonMapper.GetExpression[T,K](Expression`1 predicate) in C:\Users\micky\Documents\Source\LiteDB\LiteDB\Client\Mapper\BsonMapper.cs:line 179
   at LiteDB.LiteQueryable`1.Where(Expression`1 predicate) in C:\Users\micky\Documents\Source\LiteDB\LiteDB\Client\Database\LiteQueryable.cs:line 98
   at LiteDB.Tests.Database.MultiKey_Mapper_Tests.MyTest() in C:\Users\micky\Documents\Source\LiteDB\LiteDB.Tests\Database\MultiKey_Mapper_Tests.cs:line 71
@lbnascimento
Copy link
Contributor

@mikhail-khalizev This issue has been fixed in the master and its fix will be present in the next incremental relaese.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants