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
I think that could be a duplicate of RMLNQ-111.
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!