예제 #1
0
    public void TransformExpressions ()
    {
      var oldExpression = ExpressionHelper.CreateExpression ();
      var newExpression = ExpressionHelper.CreateExpression ();
      var clause = new MainFromClause ("x", typeof (Cook), oldExpression);

      clause.TransformExpressions (ex =>
      {
        Assert.That (ex, Is.SameAs (oldExpression));
        return newExpression;
      });

      Assert.That (clause.FromExpression, Is.SameAs (newExpression));
    }
예제 #2
0
        public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel)
        {
            base.VisitMainFromClause(fromClause, queryModel);

            ResultOperatorExpressionRewriter rewriter = new ResultOperatorExpressionRewriter();
            fromClause.TransformExpressions(rewriter.Rewrite);
            if (fromClause.FromExpression.NodeType == ExpressionType.Constant)
            {
                System.Type expressionType = queryModel.MainFromClause.FromExpression.Type;
                if (expressionType.IsGenericType && expressionType.GetGenericTypeDefinition() == typeof(NhQueryable<>))
                {
                    queryModel.MainFromClause.ItemType = expressionType.GetGenericArguments()[0];
                }
            }

            this.resultOperators.AddRange(rewriter.ResultOperators);
            this.evaluationType = rewriter.EvaluationType;
        }
 /// <summary>
 ///     This API supports the Entity Framework Core infrastructure and is not intended to be used
 ///     directly from your code. This API may change or be removed in future releases.
 /// </summary>
 public override void VisitMainFromClause(MainFromClause fromClause, QueryModel queryModel)
     => fromClause.TransformExpressions(TransformingVisitor.Visit);