ResolvingExpressionVisitor analyzes a prepared Expression for things that need to be analyzed by the IMappingResolver and resolves member accesses and similar structures. Substatements are recursively resolved. Calling ResolveExpression will automatically execute two passes in order to optimize away unnecessary left-outer joins.
Наследование: System.Linq.Expressions.ExpressionTreeVisitor, IUnresolvedSqlExpressionVisitor, ISqlSubStatementVisitor, IJoinConditionExpressionVisitor, INamedExpressionVisitor, ISqlNullCheckExpressionVisitor, ISqlInExpressionVisitor, ISqlExistsExpressionVisitor
    public static Expression ResolveExpression (
        Expression expression,
        IMappingResolver resolver,
        IMappingResolutionStage stage,
        IMappingResolutionContext context,
        UniqueIdentifierGenerator generator)
    {
      ArgumentUtility.CheckNotNull ("expression", expression);
      ArgumentUtility.CheckNotNull ("resolver", resolver);
      ArgumentUtility.CheckNotNull ("stage", stage);
      ArgumentUtility.CheckNotNull ("context", context);
      ArgumentUtility.CheckNotNull ("generator", generator);

      var entityIdentityResolver = new EntityIdentityResolver (stage, resolver, context);
      var comparisonSplitter = new CompoundExpressionComparisonSplitter();
      var namedExpressionCombiner = new NamedExpressionCombiner (context);
      var groupAggregateSimplifier = new GroupAggregateSimplifier (stage, context);

      var visitor1 = new ResolvingExpressionVisitor (
          resolver, stage, context, generator, entityIdentityResolver, comparisonSplitter, namedExpressionCombiner, groupAggregateSimplifier, false);
      var result1 = visitor1.VisitExpression (expression);

      var visitor2 = new ResolvingExpressionVisitor (
          resolver, stage, context, generator, entityIdentityResolver, comparisonSplitter, namedExpressionCombiner, groupAggregateSimplifier, true);
      var result2 = visitor2.VisitExpression (result1);
      return result2;
    }
        public static Expression ResolveExpression(
            Expression expression,
            IMappingResolver resolver,
            IMappingResolutionStage stage,
            IMappingResolutionContext context,
            UniqueIdentifierGenerator generator)
        {
            ArgumentUtility.CheckNotNull("expression", expression);
            ArgumentUtility.CheckNotNull("resolver", resolver);
            ArgumentUtility.CheckNotNull("stage", stage);
            ArgumentUtility.CheckNotNull("context", context);
            ArgumentUtility.CheckNotNull("generator", generator);

            var entityIdentityResolver   = new EntityIdentityResolver(stage, resolver, context);
            var comparisonSplitter       = new CompoundExpressionComparisonSplitter();
            var namedExpressionCombiner  = new NamedExpressionCombiner(context);
            var groupAggregateSimplifier = new GroupAggregateSimplifier(stage, context);

            var visitor1 = new ResolvingExpressionVisitor(
                resolver, stage, context, generator, entityIdentityResolver, comparisonSplitter, namedExpressionCombiner, groupAggregateSimplifier, false);
            var result1 = visitor1.Visit(expression);

            var visitor2 = new ResolvingExpressionVisitor(
                resolver, stage, context, generator, entityIdentityResolver, comparisonSplitter, namedExpressionCombiner, groupAggregateSimplifier, true);
            var result2 = visitor2.Visit(result1);

            return(result2);
        }
Пример #3
0
        protected virtual Expression ResolveExpression(Expression expression, IMappingResolutionContext context)
        {
            ArgumentUtility.CheckNotNull("expression", expression);
            ArgumentUtility.CheckNotNull("context", context);

            return(ResolvingExpressionVisitor.ResolveExpression(expression, _resolver, this, context, _uniqueIdentifierGenerator));
        }
    public void SetUp ()
    {
      _stageMock = MockRepository.GenerateStrictMock<IMappingResolutionStage>();
      _resolverMock = MockRepository.GenerateStrictMock<IMappingResolver>();
      _sqlTable = SqlStatementModelObjectMother.CreateSqlTable_WithResolvedTableInfo (typeof (Cook));
      _mappingResolutionContext = new MappingResolutionContext();
      _generator = new UniqueIdentifierGenerator();
      _entityIdentityResolverMock = MockRepository.GenerateStrictMock<IEntityIdentityResolver> ();
      _compoundComparisonSplitterMock = MockRepository.GenerateStrictMock<ICompoundExpressionComparisonSplitter> ();
      _namedExpressionCombinerMock = MockRepository.GenerateStrictMock<INamedExpressionCombiner>();
      _groupAggregateSimplifierMock = MockRepository.GenerateStrictMock<IGroupAggregateSimplifier>();

      _visitor = CreateVisitor (true);
    }