Exemple #1
0
        public IJoinInfo VisitUnresolvedCollectionJoinInfo(UnresolvedCollectionJoinInfo joinInfo)
        {
            ArgumentUtility.CheckNotNull("joinInfo", joinInfo);

            var resolvedExpression = _stage.ResolveCollectionSourceExpression(joinInfo.SourceExpression, _context);

            while (resolvedExpression is UnaryExpression)
            {
                resolvedExpression = _stage.ResolveCollectionSourceExpression(((UnaryExpression)resolvedExpression).Operand, _context);
            }

            var resolvedExpressionAsEntity = resolvedExpression as SqlEntityExpression;

            if (resolvedExpressionAsEntity != null)
            {
                var unresolvedJoinInfo = new UnresolvedJoinInfo(resolvedExpressionAsEntity, joinInfo.MemberInfo, JoinCardinality.Many);
                return(unresolvedJoinInfo.Accept(this));
            }

            var message = string.Format(
                "Only entities can be used as the collection source in from expressions, '{0}' cannot. Member: '{1}'",
                resolvedExpression,
                joinInfo.MemberInfo);

            throw new NotSupportedException(message);
        }