alirezanet/Gridify

Mongo Driver Compatibility

Azaferany opened this issue · 3 comments

Details

Version
2.7.4

Details
Hi, i to want use this package on MongoDB .NET Driver and all functionalities except Filtering work as it should.
i use ApplyFiltering on IQueryable
Screen Shot 2022-06-06 at 2 24 16 PM

and mongo driver throw below exception

System.ArgumentNullException: Value cannot be null. (Parameter 'itemName')
at MongoDB.Driver.Core.Misc.Ensure.IsNotNull[T](T value, String paramName)
at MongoDB.Driver.Linq.Linq2Implementation.Expressions.WhereExpression..ctor(Expression source, String itemName, Expression predicate)
at MongoDB.Driver.Linq.Linq2Implementation.Processors.BinderHelper.BindWhere(PipelineExpression pipeline, IBindingContext bindingContext, LambdaExpression lambda)
at MongoDB.Driver.Linq.Linq2Implementation.Processors.Pipeline.MethodCallBinders.WhereBinder.Bind(PipelineExpression pipeline, PipelineBindingContext bindingContext, MethodCallExpression node, IEnumerable1 arguments) at MongoDB.Driver.Linq.Linq2Implementation.Processors.MethodInfoMethodCallBinder1.Bind(PipelineExpression pipeline, TBindingContext bindingContext, MethodCallExpression node, IEnumerable1 arguments) at MongoDB.Driver.Linq.Linq2Implementation.Processors.PipelineBinderBase1.BindMethodCall(MethodCallExpression node)
at MongoDB.Driver.Linq.Linq2Implementation.Processors.PipelineBinderBase1.Bind(Expression node) at MongoDB.Driver.Linq.Linq2Implementation.Processors.Pipeline.PipelineBinder.Bind(Expression node, IBsonSerializerRegistry serializerRegistry) at MongoDB.Driver.Linq.Linq2Implementation.MongoQueryProviderImpl1.Prepare(Expression expression)
at MongoDB.Driver.Linq.Linq2Implementation.MongoQueryProviderImpl1.Translate(Expression expression) at MongoDB.Driver.Linq.Linq2Implementation.MongoQueryProviderImpl1.Execute(Expression expression)
at MongoDB.Driver.Linq.Linq2Implementation.MongoQueryableImpl2.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)
at .Infrastructure.RouteRepository.Find(GridifyQuery query) in /Users/almas/Desktop/.Infrastructure/RouteRepository.cs:line 25

this exception happened when lambda Parameters Name is null on where

https://github.com/mongodb/mongo-csharp-driver/blob/93614cccfa52d34a5807477df614aee6a2beb0a6/src/MongoDB.Driver/Linq/Linq2Implementation/Processors/BinderHelper.cs#L49

https://github.com/mongodb/mongo-csharp-driver/blob/93614cccfa52d34a5807477df614aee6a2beb0a6/src/MongoDB.Driver/Linq/Linq2Implementation/Expressions/WhereExpression.cs#L31

i look at CreateExpression method on GridifyMapper
i think if on

var parameter = Expression.Parameter(typeof(T));

fill Expression Parameter Name by nameof(T) it will do the work

  var parameter = Expression.Parameter(typeof(T), nameof(T));

Hi @Azaferany,

Good catch! thanks,
It is fixed in v2.7.5.

it fixed
now all function work perfect for mongo driver 🤩
i think its worth to metion mongo driver usage on docs
thanks,

now all function work perfect for mongo driver 🤩

Great 👍

i think its worth to metion mongo driver usage on docs

feel free to send a pull request 😉