Exemple #1
0
        private Expression GetIdentityExpressionForReferencedEntity(SqlEntityRefMemberExpression expression)
        {
            var optimizedIdentity = _resolver.TryResolveOptimizedIdentity(expression);

            if (optimizedIdentity != null)
            {
                return(optimizedIdentity);
            }

            var unresolvedJoinInfo = new UnresolvedJoinInfo(expression.OriginatingEntity, expression.MemberInfo, JoinCardinality.One);

            return(_stage.ResolveEntityRefMemberExpression(expression, unresolvedJoinInfo, _context).GetIdentityExpression());
        }
        public virtual Expression VisitSqlEntityRefMember(SqlEntityRefMemberExpression expression)
        {
            ArgumentUtility.CheckNotNull("expression", expression);

            if (!_resolveEntityRefMemberExpressions)
            {
                return(VisitExtension(expression));
            }

            var unresolvedJoinInfo = new UnresolvedJoinInfo(expression.OriginatingEntity, expression.MemberInfo, JoinCardinality.One);

            // No revisiting required since this visitor does not handle ISqlEntityExpressions.
            return(_stage.ResolveEntityRefMemberExpression(expression, unresolvedJoinInfo, _context));
        }
Exemple #3
0
        public Expression VisitSqlEntityRefMember(SqlEntityRefMemberExpression expression)
        {
            ArgumentUtility.CheckNotNull("expression", expression);

            // Scenario: entityRef.Member

            var result = _mappingResolver.TryResolveOptimizedMemberExpression(expression, _memberInfo);

            if (result != null)
            {
                return(result);
            }

            // Optimized member access didn't work, so resolve the entity reference (adding joins and such), then retry.
            var unresolvedJoinInfo = new UnresolvedJoinInfo(expression.OriginatingEntity, expression.MemberInfo, JoinCardinality.One);
            var entityExpression   = _stage.ResolveEntityRefMemberExpression(expression, unresolvedJoinInfo, _context);

            return(Visit(entityExpression));
        }