当前位置: 首页>>代码示例>>C#>>正文


C# QueryModel.TransformExpressions方法代码示例

本文整理汇总了C#中QueryModel.TransformExpressions方法的典型用法代码示例。如果您正苦于以下问题:C# QueryModel.TransformExpressions方法的具体用法?C# QueryModel.TransformExpressions怎么用?C# QueryModel.TransformExpressions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueryModel的用法示例。


在下文中一共展示了QueryModel.TransformExpressions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: VisitSelectClause

        public override void VisitSelectClause(SelectClause selectClause, QueryModel queryModel)
        {
            var joins = LeftJoinDetector.Detect(selectClause.Selector, new NameGenerator(queryModel), _sessionFactory);

            if (joins.Joins.Count > 0)
            {
                selectClause.Selector = joins.Selector;

                queryModel.TransformExpressions(e => ExpressionSwapper.Swap(e, joins.ExpressionMap));

                foreach (var join in joins.Joins)
                {
                    queryModel.BodyClauses.Add(join);
                }
            }
        }
开发者ID:pruiz,项目名称:nhibernate-old,代码行数:16,代码来源:AddLeftJoinsReWriter.cs

示例2: JoinReplacer

		private Expression JoinReplacer(QueryModel queryModel, Expression expression)
		{
			var joins = LeftJoinDetector.Detect(expression, new NameGenerator(queryModel), _sessionFactory);

			Expression result = expression;

			if (joins.Joins.Count > 0)
			{
				result = joins.Selector;

				queryModel.TransformExpressions(e => ExpressionSwapper.Swap(e, joins.ExpressionMap));

				foreach (var join in joins.Joins)
				{
					queryModel.BodyClauses.Add(join);
				}
			}

			return result;
		}
开发者ID:briandonahue,项目名称:nhibernate,代码行数:20,代码来源:AddLeftJoinsReWriter.cs

示例3: FlattenSubQuery

    protected virtual void FlattenSubQuery (
        SubQueryExpression subQueryExpression, FromClauseBase fromClause, QueryModel queryModel, int destinationIndex)
    {
      ArgumentUtility.CheckNotNull ("subQueryExpression", subQueryExpression);
      ArgumentUtility.CheckNotNull ("fromClause", fromClause);
      ArgumentUtility.CheckNotNull ("queryModel", queryModel);

      CheckFlattenable (subQueryExpression.QueryModel);

      var innerMainFromClause = subQueryExpression.QueryModel.MainFromClause;
      CopyFromClauseData (innerMainFromClause, fromClause);

      var innerSelectorMapping = new QuerySourceMapping();
      innerSelectorMapping.AddMapping (fromClause, subQueryExpression.QueryModel.SelectClause.Selector);
      queryModel.TransformExpressions (ex => ReferenceReplacingExpressionTreeVisitor.ReplaceClauseReferences (ex, innerSelectorMapping, false));

      InsertBodyClauses (subQueryExpression.QueryModel.BodyClauses, queryModel, destinationIndex);

      var innerBodyClauseMapping = new QuerySourceMapping();
      innerBodyClauseMapping.AddMapping (innerMainFromClause, new QuerySourceReferenceExpression (fromClause));
      queryModel.TransformExpressions (ex => ReferenceReplacingExpressionTreeVisitor.ReplaceClauseReferences (ex, innerBodyClauseMapping, false));
    }
开发者ID:GOArango,项目名称:arangoclient.net,代码行数:22,代码来源:SubQueryFromClauseFlattener.cs

示例4: ReWrite

		public static void ReWrite(QueryModel model)
		{
			var visitor = new QueryReferenceExpressionFlattener();
			model.TransformExpressions(visitor.VisitExpression);
		}
开发者ID:paulbatum,项目名称:nhibernate,代码行数:5,代码来源:QueryReferenceExpressionFlattener.cs

示例5: TransformExpressions

    public void TransformExpressions ()
    {
      var fromClause = new MainFromClause ("item", typeof (string), ExpressionHelper.CreateExpression());
      var selectClause = new SelectClause (ExpressionHelper.CreateExpression());
      var bodyClauseMock = MockRepository.GenerateMock<IBodyClause>();

      var oldFromExpression = fromClause.FromExpression;
      var newFromExpression = ExpressionHelper.CreateExpression();

      var oldSelectorExpression = selectClause.Selector;
      var newSelectorExpression = ExpressionHelper.CreateExpression();

      Func<Expression, Expression> transformation = ex =>
      {
        if (ex == oldFromExpression)
          return newFromExpression;
        if (ex == oldSelectorExpression)
          return newSelectorExpression;
        else
          return ex;
      };

      var queryModel = new QueryModel (fromClause, selectClause);
      queryModel.BodyClauses.Add (bodyClauseMock);

      queryModel.TransformExpressions (transformation);

      Assert.That (fromClause.FromExpression, Is.SameAs (newFromExpression));
      Assert.That (selectClause.Selector, Is.SameAs (newSelectorExpression));
      bodyClauseMock.AssertWasCalled (mock => mock.TransformExpressions (transformation));
    }
开发者ID:natemcmaster,项目名称:Relinq,代码行数:31,代码来源:QueryModelTest.cs

示例6: TransformExpressions

    public void TransformExpressions ()
    {
      Func<Expression, Expression> transformation = ex => ex;
      var fromClauseMock = MockRepository.GenerateMock<MainFromClause> ("item", typeof (string), ExpressionHelper.CreateExpression());
      var bodyClauseMock = MockRepository.GenerateMock<IBodyClause>();
      var selectClauseMock = MockRepository.GenerateMock<SelectClause> (ExpressionHelper.CreateExpression());

      var queryModel = new QueryModel (fromClauseMock, selectClauseMock);
      queryModel.BodyClauses.Add (bodyClauseMock);

      queryModel.TransformExpressions (transformation);

      fromClauseMock.AssertWasCalled (mock => mock.TransformExpressions (transformation));
      bodyClauseMock.AssertWasCalled (mock => mock.TransformExpressions (transformation));
      selectClauseMock.AssertWasCalled (mock => mock.TransformExpressions (transformation));
    }
开发者ID:hong1990,项目名称:Relinq,代码行数:16,代码来源:QueryModelTest.cs


注:本文中的QueryModel.TransformExpressions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。