-
Type:
Bug
-
Resolution: Done
-
Priority:
Major - P3
-
None
-
Affects Version/s: 2.2.4
-
Component/s: LINQ
-
None
-
Environment:Windows 7
-
None
-
None
-
None
-
None
-
None
-
None
-
None
When using the Join operation on an IQueryable the operation throws an exception in the following circumstances
1. Join one typed collection's items to another on an integer field; Queryable of Item A to Queryable Item B
2. Filter the resultant items (Item B) using a where for example
3. Join the the resultant items back to their parent items; Queryable of Item B to Queryable of Item A
4. Execute the resultant query via a call to toArray(), giving an array of item A.
On the call to toArray() the following exception is thrown:
Test method MongoInvestigation.Test.UnitTest1.TestMethod1 threw exception: System.ArgumentException: Expression of type 'System.Collections.Generic.IEnumerable`1[MongoInvestigation.Test.UnitTest1+Order]' cannot be used for parameter of type 'System.Linq.IQueryable`1[MongoInvestigation.Test.UnitTest1+Order]' of method 'System.Linq.IQueryable`1[MongoInvestigation.Test.UnitTest1+Product] Join[Order,Product,Int32,Product](System.Linq.IQueryable`1[MongoInvestigation.Test.UnitTest1+Order], System.Collections.Generic.IEnumerable`1[MongoInvestigation.Test.UnitTest1+Product], System.Linq.Expressions.Expression`1[System.Func`2[MongoInvestigation.Test.UnitTest1+Order,System.Int32]], System.Linq.Expressions.Expression`1[System.Func`2[MongoInvestigation.Test.UnitTest1+Product,System.Int32]], System.Linq.Expressions.Expression`1[System.Func`3[MongoInvestigation.Test.UnitTest1+Order,MongoInvestigation.Test.UnitTest1+Product,MongoInvestigation.Test.UnitTest1+Product]])' at System.Linq.Expressions.Expression.ValidateOneArgument(MethodBase method, ExpressionType nodeKind, Expression arg, ParameterInfo pi) at System.Linq.Expressions.Expression.ValidateArgumentTypes(MethodBase method, ExpressionType nodeKind, ReadOnlyCollection`1& arguments) at System.Linq.Expressions.Expression.Call(Expression instance, MethodInfo method, IEnumerable`1 arguments) at System.Linq.Expressions.MethodCallExpressionN.Rewrite(Expression instance, IList`1 args) at MongoDB.Driver.Linq.Processors.SerializationBinder.Visit(Expression node) at System.Linq.Expressions.ExpressionVisitor.Visit(ReadOnlyCollection`1 nodes) at MongoDB.Driver.Linq.Processors.SerializationBinder.BindEmbeddedPipeline(MethodCallExpression node) at MongoDB.Driver.Linq.Processors.SerializationBinder.Visit(Expression node) at MongoDB.Driver.Linq.Processors.Pipeline.MethodCallBinders.JoinBinder.Bind(PipelineExpression pipeline, PipelineBindingContext bindingContext, MethodCallExpression node, IEnumerable`1 arguments) at MongoDB.Driver.Linq.Processors.MethodInfoMethodCallBinder`1.Bind(PipelineExpression pipeline, TBindingContext bindingContext, MethodCallExpression node, IEnumerable`1 arguments) at MongoDB.Driver.Linq.Processors.PipelineBinderBase`1.BindMethodCall(MethodCallExpression node) at MongoDB.Driver.Linq.Processors.PipelineBinderBase`1.Bind(Expression node) at MongoDB.Driver.Linq.Processors.Pipeline.PipelineBinder.Bind(Expression node, IBsonSerializerRegistry serializerRegistry) at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Prepare(Expression expression) at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Translate(Expression expression) at MongoDB.Driver.Linq.MongoQueryProviderImpl`1.Execute(Expression expression) at MongoDB.Driver.Linq.MongoQueryableImpl`2.GetEnumerator() at System.Linq.Buffer`1..ctor(IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at MongoInvestigation.Test.UnitTest1.<TestMethod1>d__2.MoveNext() in C:\GITProjects\MongoInvestigation\MongoInvestigation.Test\UnitTest1.cs:line 46 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Please see attached code for full reproduction