We're updating the issue view to help you get more done. 

QueryModel: cloning doesn't work if the same subquery is present twice in the QM that is being cloned

Description

Repro:

QM created by the parser looks like this:

The subquery assigned to Permissions binding is repeated (same reference). This causes problems when cloning:

{"Query source (from RelinqProjectUser u in [p].ProjectUsers) has already been associated with an expression."}

at Remotion.Linq.Clauses.QuerySourceMapping.AddMapping(IQuerySource querySource, Expression expression)
at Remotion.Linq.Clauses.MainFromClause.Clone(CloneContext cloneContext)
at Remotion.Linq.QueryModel.Clone(QuerySourceMapping querySourceMapping)
at Remotion.Linq.QueryModel.CloningExpressionVisitor.VisitSubQuery(SubQueryExpression expression)
at Remotion.Linq.Clauses.Expressions.SubQueryExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at System.Linq.Expressions.ExpressionVisitor.VisitMemberAssignment(MemberAssignment node)
at System.Linq.Expressions.ExpressionVisitor.VisitMemberBinding(MemberBinding node)
at System.Linq.Expressions.ExpressionVisitor.Visit[T](ReadOnlyCollection`1 nodes, Func`2 elementVisitor)
at System.Linq.Expressions.ExpressionVisitor.VisitMemberInit(MemberInitExpression node)
at System.Linq.Expressions.MemberInitExpression.Accept(ExpressionVisitor visitor)
at System.Linq.Expressions.ExpressionVisitor.Visit(Expression node)
at Remotion.Linq.Clauses.SelectClause.TransformExpressions(Func`2 transformation)
at Remotion.Linq.QueryModel.TransformExpressions(Func`2 transformation)
at Remotion.Linq.QueryModel.Clone(QuerySourceMapping querySourceMapping)
at Microsoft.EntityFrameworkCore.Query.QueryBugsTest.RelinqCloningBug() in

Activity

Show:
Michael Ketting
October 20, 2017, 5:58 AM

I think that could be a duplicate of RMLNQ-111.

User known
January 9, 2018, 5:29 AM

Just to let you know, I tested alpha-004 in my code base against my private test cases that look for this and it fails. Looking forward to testing alpha-005 when it appears on nuget!

Assignee

Michael Ketting

Reporter

User known

Labels

Components

Fix versions

Priority

Normal
Configure