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


C# Expressions.SubQueryExpression类代码示例

本文整理汇总了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;
    }
开发者ID:natemcmaster,项目名称:Relinq,代码行数:7,代码来源:ReferenceReplacingExpressionVisitor.cs

示例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);
		}
开发者ID:nikson,项目名称:nhibernate-core,代码行数:28,代码来源:SelectClauseRewriter.cs

示例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);
		}
开发者ID:marchlud,项目名称:nhibernate-core,代码行数:27,代码来源:NonAggregatingGroupByRewriter.cs

示例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);
        }
开发者ID:umittal,项目名称:MunimJi,代码行数:29,代码来源:AggregatingGroupByRewriter.cs

示例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);
 }
开发者ID:Zaixu,项目名称:Lucene.Net.Linq,代码行数:7,代码来源:AggressiveSubQueryFromClauseFlattener.cs

示例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
    }
开发者ID:natemcmaster,项目名称:Relinq,代码行数:7,代码来源:TransparentIdentifierRemovingExpressionVisitor.cs

示例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));
    }
开发者ID:hong1990,项目名称:Relinq,代码行数:7,代码来源:CloningExpressionTreeVisitorTest.cs

示例9: VisitSubQueryExpression

    protected override Expression VisitSubQueryExpression (SubQueryExpression expression)
    {
      ArgumentUtility.CheckNotNull ("expression", expression);

      var clonedQueryModel = expression.QueryModel.Clone (QuerySourceMapping);
      return new SubQueryExpression (clonedQueryModel);
    }
开发者ID:GTuritto,项目名称:BrightstarDB,代码行数:7,代码来源:CloningExpressionTreeVisitor.cs

示例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;
        }
开发者ID:nutrija,项目名称:revenj,代码行数:32,代码来源:SumProjection.cs

示例11: VisitSubQueryExpression

        protected override Expression VisitSubQueryExpression(SubQueryExpression expression)
        {
            ContainsAggregateMethods =
                new GroupByAggregateDetectionVisitor().Visit(expression.QueryModel.SelectClause.Selector);

            return expression;
        }
开发者ID:umittal,项目名称:MunimJi,代码行数:7,代码来源:GroupByAggregateDetectionVisitor.cs

示例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));
    }
开发者ID:hong1990,项目名称:Relinq,代码行数:7,代码来源:ReferenceReplacingExpressionTreeVisitorTest.cs

示例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));
 }
开发者ID:hong1990,项目名称:Relinq,代码行数:8,代码来源:SubQueryExpressionTest.cs

示例15: VisitSubQuery

        protected override Expression VisitSubQuery(SubQueryExpression expression)
        {
            var clonedModel = expression.QueryModel.Clone();

            clonedModel.TransformExpressions(Visit);

            return new SubQueryExpression(clonedModel);
        }
开发者ID:rbenhassine2,项目名称:EntityFramework,代码行数:8,代码来源:FunctionEvaluationDisablingVisitor.cs


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