IQueryable<T> implementation failes with OData $expand operation used againt collection with TypeMismatchException

Description

Attaching test project. Following queries are used to test with later is failing:
http://localhost:51843/WebApi/Products
http://localhost:51843/WebApi/Products?$expand=Owner
http://localhost:51843/WebApi/Products?$expand=Inventories
Stack Trace:
message":"The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.","type":"System.InvalidOperationException","stacktrace":"","internalexception":{ "message":"\u0422\u0438\u043f\u044b \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u044e\u0442","type":"System.ArgumentException","stacktrace":" \u0432 System.Linq.Expressions.Expression.Condition(Expression test, Expression ifTrue, Expression ifFalse)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitConditionalExpression(ConditionalExpression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
\u0432 NHibernate.Linq.NestedSelects.SelectClauseRewriter.VisitExpression(Expression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitBinaryExpression(BinaryExpression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
\u0432 NHibernate.Linq.NestedSelects.SelectClauseRewriter.VisitExpression(Expression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitConditionalExpression(ConditionalExpression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
\u0432 NHibernate.Linq.NestedSelects.SelectClauseRewriter.VisitExpression(Expression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment memberAssigment)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberBinding(MemberBinding memberBinding)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList(ReadOnlyCollection`1 list, Func`2 visitMethod)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberBindingList(ReadOnlyCollection`1 expressions)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
\u0432 NHibernate.Linq.NestedSelects.SelectClauseRewriter.VisitExpression(Expression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberAssignment(MemberAssignment memberAssigment)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberBinding(MemberBinding memberBinding)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitList(ReadOnlyCollection`1 list, Func`2 visitMethod)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberBindingList(ReadOnlyCollection`1 expressions)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitMemberInitExpression(MemberInitExpression expression)
\u0432 Remotion.Linq.Parsing.ExpressionTreeVisitor.VisitExpression(Expression expression)
\u0432 NHibernate.Linq.NestedSelects.SelectClauseRewriter.VisitExpression(Expression expression)
\u0432 NHibernate.Linq.NestedSelects.NestedSelectRewriter.ReWrite(QueryModel queryModel, ISessionFactory sessionFactory)
\u0432 NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root)
\u0432 NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory, Boolean filter)
\u0432 NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)
\u0432 NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)
\u0432 NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)
\u0432 NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)
\u0432 NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, ref IQuery query, ref NhLinqExpression nhQuery)
\u0432 NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
\u0432 NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)
\u0432 Remotion.Linq.QueryableBase`1.System.Collections.IEnumerable.GetEnumerator()
\u0432 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteFeed(IEnumerable enumerable, IEdmTypeReference feedType, ODataWriter writer, ODataSerializerContext writeContext)
\u0432 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObjectInline(Object graph, IEdmTypeReference expectedType, ODataWriter writer, ODataSerializerContext writeContext)
\u0432 System.Web.Http.OData.Formatter.Serialization.ODataFeedSerializer.WriteObject(Object graph, Type type, ODataMessageWriter messageWriter, ODataSerializerContext writeContext)
\u0432 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content, HttpContentHeaders contentHeaders)
\u0432 System.Web.Http.OData.Formatter.ODataMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext)
— \u041a\u043e\u043d\u0435\u0446 \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u0442\u0435\u043a\u0430 \u0438\u0437 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0433\u0434\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 — \u0432System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
\u0432 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
\u0432 System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__14.MoveNext()"

Environment

Asp.Net MVC 5 Web API host with OData Controller

Assignee

Unassigned

Reporter

Dmitry Mokhnatov

Labels

Components

Affects versions

Priority

Major
Configure