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

Tokenizer exception when trying to use .Contains on a supplied IEnumerable #6

Open
hidegh opened this issue Jun 23, 2021 · 0 comments
Assignees

Comments

@hidegh
Copy link

hidegh commented Jun 23, 2021

DynamicQueryable version

2.0.25

Steps to reproduce

The simplest sample code to reproduce:

var sample = new[] { 1, 2, 3, 4, 5 };
var result = sample.AsQueryable().Where($"i => @0.Contains(i)", sample).ToList();

Expected behavior

Execution and the desired items to be selected (originally you'd call the .Where on a DBSet)...

Actual behavior

Tokenizer fails on .Contains:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Jokenizer.Net
  StackTrace:
   at Jokenizer.Net.ExtensionMethods.<>c__DisplayClass9_0.<GetExtensionMethod>b__0(MethodInfo m)
   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Jokenizer.Net.ExtensionMethods.GetExtensionMethod(Type forType, String name, Int32 parameterCount)
   at Jokenizer.Net.TokenVisitor.GetMethod(Expression owner, String name, Int32 parameterCount)
   at Jokenizer.Net.TokenVisitor.VisitCall(CallToken token, IEnumerable`1 parameters)
   at Jokenizer.Net.TokenVisitor.Visit(Token token, IEnumerable`1 parameters)
   at Jokenizer.Net.TokenVisitor.VisitLambda(LambdaToken token, IEnumerable`1 typeParameters, IEnumerable`1 parameters)
   at Jokenizer.Net.TokenVisitor.Process(Token token, IEnumerable`1 typeParameters, IEnumerable`1 parameters)
   at Jokenizer.Net.Evaluator.ToLambda(Token token, IEnumerable`1 typeParameters, IDictionary`2 variables, Object[] parameters)
   at Jokenizer.Net.Evaluator.ToLambda(String token, IEnumerable`1 typeParameters, IDictionary`2 variables, Object[] parameters)
   at System.Linq.Dynamic.DynamicQueryable.CreateLambda(IQueryable source, String method, String expression, Boolean generic, IDictionary`2 variables, Object[] values)
   at System.Linq.Dynamic.DynamicQueryable.HandleLambda(IQueryable source, String method, String expression, Boolean generic, IDictionary`2 variables, Object[] values)
   at System.Linq.Dynamic.DynamicQueryable.Where(IQueryable source, String predicate, IDictionary`2 variables, Object[] values)
   at System.Linq.Dynamic.DynamicQueryable.Where[T](IQueryable`1 source, String predicate, IDictionary`2 variables, Object[] values)
   at System.Linq.Dynamic.DynamicQueryable.Where[T](IQueryable`1 source, String predicate, Object[] values)
   at TeamLead.Code.Services.Sync.GenericSync.Sync[TApiDto,TEntity,TId](String prefix, Int32 batchSize, Boolean shouldUpdate, Boolean shouldInsert, Boolean shouldDelete, SbApiFetchConfig`2 apiFetchConfig, DbFetchConfig`2 dbFetchConfig, Action`2 mapper) in C:\$_Work\SP.TeamLead\TeamLead\Code\Services\Sync\GenericSync.cs:line 87
@umutozel umutozel self-assigned this Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants