本文整理汇总了C#中Remotion.Linq.Clauses.Expressions.SubQueryExpression类的典型用法代码示例。如果您正苦于以下问题:C# SubQueryExpression类的具体用法?C# SubQueryExpression怎么用?C# SubQueryExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubQueryExpression类属于Remotion.Linq.Clauses.Expressions命名空间,在下文中一共展示了SubQueryExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitSubQuery
protected internal override Expression VisitSubQuery (SubQueryExpression expression)
{
ArgumentUtility.CheckNotNull ("expression", expression);
expression.QueryModel.TransformExpressions (ex => ReplaceClauseReferences (ex, _querySourceMapping, _throwOnUnmappedReferences));
return expression;
}
示例2: FlattenSubQuery
private void FlattenSubQuery(SubQueryExpression subQueryExpression, QueryModel queryModel)
{
// Create a new client-side select for the outer
// TODO - don't like calling GetGenericArguments here...
var clientSideSelect = new ClientSideSelect(
new NonAggregatingGroupBySelectRewriter()
.Visit(queryModel.SelectClause.Selector, subQueryExpression.Type.GetGenericArguments()[0], queryModel.MainFromClause));
// Replace the outer select clause...
queryModel.SelectClause = subQueryExpression.QueryModel.SelectClause;
// Replace the outer from clause...
queryModel.MainFromClause = subQueryExpression.QueryModel.MainFromClause;
foreach (var bodyClause in subQueryExpression.QueryModel.BodyClauses)
{
queryModel.BodyClauses.Add(bodyClause);
}
// Move the result operator up
if (queryModel.ResultOperators.Count != 0)
{
throw new NotImplementedException();
}
queryModel.ResultOperators.Add(new NonAggregatingGroupBy((GroupResultOperator)subQueryExpression.QueryModel.ResultOperators[0]));
queryModel.ResultOperators.Add(clientSideSelect);
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:28,代码来源:NonAggregatingGroupByRewriter.cs
示例3: VisitSubQueryExpression
protected override Expression VisitSubQueryExpression(SubQueryExpression expression)
{
var selector = expression.QueryModel.SelectClause.Selector;
var value = Expression.Parameter(typeof (Tuple), "value");
var rewriter = new SelectClauseRewriter(value, values, expressions, tuple + 1);
var resultSelector = rewriter.VisitExpression(selector);
var where = EnumerableHelper.GetMethod("Where",
new[] {typeof (IEnumerable<>), typeof (Func<,>)},
new[] {Tuple.Type});
var select = EnumerableHelper.GetMethod("Select",
new[] {typeof (IEnumerable<>), typeof (Func<,>)},
new[] {Tuple.Type, selector.Type});
var toList = EnumerableHelper.GetMethod("ToList",
new[] {typeof (IEnumerable<>)},
new[] {selector.Type});
return Expression.Call(Expression.Call(toList,
Expression.Call(select,
Expression.Call(where, values, WherePredicate),
Expression.Lambda(resultSelector, value))),
"AsReadOnly", System.Type.EmptyTypes);
}
示例4: FlattenSubQuery
private static void FlattenSubQuery(SubQueryExpression subQueryExpression, QueryModel queryModel)
{
// Create a new client-side select for the outer
var clientSideSelect = CreateClientSideSelect(subQueryExpression, queryModel);
var subQueryModel = subQueryExpression.QueryModel;
// Replace the outer select clause...
queryModel.SelectClause = subQueryModel.SelectClause;
// Replace the outer from clause...
queryModel.MainFromClause = subQueryModel.MainFromClause;
foreach (var bodyClause in subQueryModel.BodyClauses)
{
queryModel.BodyClauses.Add(bodyClause);
}
// Move the result operator up
if (queryModel.ResultOperators.Count != 0)
{
throw new NotImplementedException();
}
queryModel.ResultOperators.Add(new NonAggregatingGroupBy((GroupResultOperator) subQueryModel.ResultOperators[0]));
queryModel.ResultOperators.Add(clientSideSelect);
}
示例5: FlattenSubQuery
private void FlattenSubQuery(SubQueryExpression subQueryExpression, FromClauseBase fromClause,
QueryModel queryModel)
{
// Move the result operator up
if (queryModel.ResultOperators.Count != 0)
{
throw new NotImplementedException();
}
var groupBy = (GroupResultOperator) subQueryExpression.QueryModel.ResultOperators[0];
// Replace the outer select clause...
queryModel.SelectClause.TransformExpressions(s => GroupBySelectClauseRewriter.ReWrite(s, groupBy, subQueryExpression.QueryModel));
queryModel.SelectClause.TransformExpressions(
s =>
new SwapQuerySourceVisitor(queryModel.MainFromClause, subQueryExpression.QueryModel.MainFromClause).Swap
(s));
MainFromClause innerMainFromClause = subQueryExpression.QueryModel.MainFromClause;
CopyFromClauseData(innerMainFromClause, fromClause);
foreach (var bodyClause in subQueryExpression.QueryModel.BodyClauses)
{
queryModel.BodyClauses.Add(bodyClause);
}
queryModel.ResultOperators.Add(groupBy);
}
示例6: FlattenSubQuery
protected override void FlattenSubQuery(SubQueryExpression subQueryExpression, FromClauseBase fromClause, QueryModel queryModel,
int destinationIndex)
{
var subQueryModel = subQueryExpression.QueryModel;
MoveResultOperatorsToParent(queryModel, subQueryModel);
base.FlattenSubQuery(subQueryExpression, fromClause, queryModel, destinationIndex);
}
示例7: VisitSubQuery
protected internal override Expression VisitSubQuery (SubQueryExpression expression)
{
ArgumentUtility.CheckNotNull ("expression", expression);
expression.QueryModel.TransformExpressions (ReplaceTransparentIdentifiers);
return expression; // Note that we modifiy the (mutable) QueryModel, we return an unchanged expression
}
示例8: Replaces_SubQueryExpressions
public void Replaces_SubQueryExpressions ()
{
var expression = new SubQueryExpression (ExpressionHelper.CreateQueryModel<Cook> ());
var result = CloningExpressionTreeVisitor.AdjustExpressionAfterCloning (expression, _querySourceMapping);
Assert.That (((SubQueryExpression) result).QueryModel, Is.Not.SameAs (expression.QueryModel));
}
示例9: VisitSubQueryExpression
protected override Expression VisitSubQueryExpression (SubQueryExpression expression)
{
ArgumentUtility.CheckNotNull ("expression", expression);
var clonedQueryModel = expression.QueryModel.Clone (QuerySourceMapping);
return new SubQueryExpression (clonedQueryModel);
}
示例10: CheckShortCircuitSum
private static bool CheckShortCircuitSum(SubQueryExpression expression, MainQueryParts queryParts, Action<Expression> visitExpression)
{
var subquery = SubqueryGeneratorQueryModelVisitor.ParseSubquery(expression.QueryModel, queryParts, true);
if (subquery.ShouldQueryInMemory)
{
throw new NotImplementedException("Unsupported subquery. Please provide more info about query.");
//return false;
}
var sql = subquery.BuildSqlString(false);
var cnt = queryParts.CurrentSelectIndex;
var selector = expression.QueryModel.SelectClause.Selector as MemberExpression;
if (selector == null)
return false;
var type = expression.QueryModel.ResultTypeOverride;
if (type.IsNullable())
type = type.GetGenericArguments()[0];
queryParts.AddSelectPart(
expression.QueryModel.MainFromClause,
@"(SELECT SUM((""{1}"").""{3}"") FROM ({2}) ""{1}"") AS ""{0}""".With(
"_subquery_" + cnt,
expression.QueryModel.MainFromClause.ItemName,
sql,
selector.Member.Name),
"_sum_" + cnt,
expression.QueryModel.ResultTypeOverride,
(_, dr) => dr.IsDBNull(cnt) ? 0 : Convert.ChangeType(dr.GetValue(cnt), type));
return true;
}
示例11: VisitSubQueryExpression
protected override Expression VisitSubQueryExpression(SubQueryExpression expression)
{
ContainsAggregateMethods =
new GroupByAggregateDetectionVisitor().Visit(expression.QueryModel.SelectClause.Selector);
return expression;
}
示例12: VisitSubQuery_ExpressionUnchanged
public void VisitSubQuery_ExpressionUnchanged ()
{
var expression = new SubQueryExpression (ExpressionHelper.CreateQueryModel<Cook> ());
var result = ReferenceReplacingExpressionTreeVisitor.ReplaceClauseReferences (expression, _querySourceMapping, false);
Assert.That (((SubQueryExpression) result).QueryModel, Is.SameAs (expression.QueryModel));
}
示例13: VisitSubQueryExpression
protected override Expression VisitSubQueryExpression(SubQueryExpression subQuery)
{
var hasBodyClauses = subQuery.QueryModel.BodyClauses.Count > 0;
if(hasBodyClauses)
{
return base.VisitSubQueryExpression(subQuery);
}
var resultOperators = subQuery.QueryModel.ResultOperators;
if (resultOperators.Count == 0 || HasJustAllFlattenableOperator(resultOperators))
{
var selectQuerySource = subQuery.QueryModel.SelectClause.Selector as QuerySourceReferenceExpression;
if (selectQuerySource != null && selectQuerySource.ReferencedQuerySource == subQuery.QueryModel.MainFromClause)
{
foreach (var resultOperator in resultOperators)
{
_model.ResultOperators.Add(resultOperator);
}
return subQuery.QueryModel.MainFromClause.FromExpression;
}
}
return base.VisitSubQueryExpression(subQuery);
}
开发者ID:khaliyo,项目名称:Spring.net-NHibernate.net-Asp.net-MVC-DWZ-,代码行数:25,代码来源:QueryReferenceExpressionFlattener.cs
示例14: Initialization
public void Initialization ()
{
var queryModel = ExpressionHelper.CreateQueryModel<Cook>();
var expression = new SubQueryExpression (queryModel);
Assert.That (expression.Type, Is.SameAs (typeof(IQueryable<Cook>)));
Assert.That (expression.QueryModel, Is.SameAs (queryModel));
Assert.That (expression.NodeType, Is.EqualTo (SubQueryExpression.ExpressionType));
}
示例15: VisitSubQuery
protected override Expression VisitSubQuery(SubQueryExpression expression)
{
var clonedModel = expression.QueryModel.Clone();
clonedModel.TransformExpressions(Visit);
return new SubQueryExpression(clonedModel);
}