You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.15.0, I can't use 2.16 since I use dotnet 9 but EF 8, the bug should be present in latest also.
Details
I was trying to add a map like this:
Mapper.AddMap(nameof(Entry.LexemeForm),(entry,key)=>Json.Value(entry.LexemeForm, ms =>ms[key]));
and when I try to generate an expression it throws. I would expect it to just work. As a workaround I was able to disable null index checking.
Steps to reproduce
Add a map like this Mapper.AddMap(nameof(Entry.LexemeForm), (entry, key) => Json.Value(entry.LexemeForm, ms => ms[key]));
use that property in a filter like LexemeForm[en]=test
convert to express
get exception:
Object reference not set to an instance of an object.
at Gridify.Builder.BaseQueryBuilder`2.AddIndexerNullCheck(LambdaExpression mapTarget, Object query)
at Gridify.Builder.BaseQueryBuilder`2.ConvertBinaryExpressionSyntaxToQuery(BinaryExpressionSyntax binarySyntax)
at Gridify.Builder.BaseQueryBuilder`2.BuildQuery(ExpressionSyntax expression, Boolean isParenthesisOpen)
at Gridify.Builder.BaseQueryBuilder`2.Build(ExpressionSyntax expression)
debugging it I found that line 147 throws because methodCallExpression.Object is null.
Hi @hahn-kev,
I'm not sure If I fully understand the problem, Please provide a reproducable example (maybe include the model and explain what is the Json.Value that you're trying to use and why?)
if you could create a Test-case showing the problem, it is much easier to debug and resolve generally.
Sure thing, in this case that call is just transformed from an Expression by Linq2Db into SQL. But I can come up with a simple reproduction to make it easy to test the bug.
varquery=newGridifyQuery(){Filter="MetaDataDefined[CreatedOn]=false"};varmapper=newGridifyMapper<Person>();mapper.Configuration.DisableCollectionNullChecks=false;//true works around the issuemapper.AddMap("MetaDataDefined",(person,key)=>Utils.IsDefined(person.MetaData,key));varexpression=query.GetFilteringExpression(mapper);//throwsclassPerson{publicDictionary<string,string>MetaData{get;set;}}classUtils{publicstaticboolIsDefined(Dictionary<string,string>dict,stringkey){returndict.TryGetValue(key,out_);}}
In my case I'm using Gridify with Linq2db which I can configure to rewrite Utils.IsDefined into SQL, but that's not important here.
Another workaround but doesn't actually work for me would be to move IsDefined to be an instance method on Person and then configure the mapper like this:
Version
2.15.0, I can't use 2.16 since I use dotnet 9 but EF 8, the bug should be present in latest also.
Details
I was trying to add a map like this:
and when I try to generate an expression it throws. I would expect it to just work. As a workaround I was able to disable null index checking.
Steps to reproduce
Mapper.AddMap(nameof(Entry.LexemeForm), (entry, key) => Json.Value(entry.LexemeForm, ms => ms[key]));
LexemeForm[en]=test
debugging it I found that line 147 throws because
methodCallExpression.Object
is null.Gridify/src/Gridify/Builder/BaseQueryBuilder.cs
Lines 136 to 153 in ad89906
The text was updated successfully, but these errors were encountered: