本文整理汇总了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);
}
}
}
示例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;
}
示例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));
}
示例4: ReWrite
public static void ReWrite(QueryModel model)
{
var visitor = new QueryReferenceExpressionFlattener();
model.TransformExpressions(visitor.VisitExpression);
}
示例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));
}
示例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));
}