mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.58k stars 1.25k forks source link

System.NotSupportedException #1294

Open krenukumar opened 5 years ago

krenukumar commented 5 years ago

We are using LiteRepository . It is working fine until update to 5.0.0-alpha. Updated the calls according to the new implementation. But failing while converting predicate to BsonExpression.

Stack:

System.NotSupportedException: 'Method Contains(Func<T,TResult>) in Enumerable are not supported when convert to BsonExpression (value(Agner.Helpers.CallDataHelper+<>c__DisplayClass1_0).allstocks.SelectMany(x => x.ContactIds).Distinct().Contains(e.MobileId)).'

at LiteDB.LinqExpressionVisitor.VisitMethodCall(MethodCallExpression node) at System.Linq.Expressions.ExpressionVisitor.VisitLambda[T](Expression1 node) at LiteDB.LinqExpressionVisitor.VisitLambda[T](Expression1 node) at LiteDB.LinqExpressionVisitor.Resolve(Expression expr, Boolean predicate, Boolean extend) at LiteDB.LiteQueryable1.Where(Expression1 predicate) at LiteDB.LiteRepository.Fetch[T](Expression1 predicate, String collectionName) at Agner.Repository.Get[T](Expression1 query) in C:\Agner\Repository.cs:line 36 at Agner.Helpers.CallDataHelper.GetAttachedItems(IEnumerable1 calls, IEnumerable1 IRepository repository) in C:\Agner\Helpers\CallDataHelper.cs:line 27 at Agner.Helpers.CallDataHelper.GetStocks(IRepository repository, ICace cace) in C:\Agner\Helpers\CallDataHelper.cs:line 17 at Agner.DashboardViewModel.b__180_0() in C:\Agner\DashboardViewModel.cs:line 379 at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)

mbdavid commented 5 years ago

Hi @krenukumar, can you test with current master branch? I fix Contains method, must be fixed for your case. Will be released in next beta version