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


C# ColumnExpression.GreaterThan方法代码示例

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


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

示例1: VisitSelect

		protected override Expression VisitSelect(SelectExpression select)
		{
			select = (SelectExpression)base.VisitSelect(select);
			if (select.Skip != null)
			{
				SelectExpression newSelect = select.SetSkip(null).SetTake(null);
				bool canAddColumn = !select.IsDistinct && (select.GroupBy == null || select.GroupBy.Count == 0);
				if (!canAddColumn)
				{
					newSelect = newSelect.AddRedundantSelect(new TableAlias());
				}

				var colType = DbTypeSystem.GetColumnType(typeof(int));
				newSelect = newSelect.AddColumn(new ColumnDeclaration(columnName, new RowNumberExpression(select.OrderBy), colType));

				// add layer for WHERE clause that references new rownum column
				newSelect = newSelect.AddRedundantSelect(new TableAlias());
				newSelect = newSelect.RemoveColumn(newSelect.Columns.Single(c => c.Name == columnName));

				var newAlias = ((SelectExpression)newSelect.From).Alias;
				ColumnExpression rnCol = new ColumnExpression(typeof(int), colType, newAlias, columnName);
				Expression where;

				if (select.Take != null)
				{
					where = new BetweenExpression(
						rnCol, Expression.Add(select.Skip, Expression.Constant(1)), Expression.Add(select.Skip, select.Take));
				}
				else
				{
					where = rnCol.GreaterThan(select.Skip);
				}

				if (newSelect.Where != null)
				{
					where = newSelect.Where.And(where);
				}

				newSelect = newSelect.SetWhere(where);

				select = newSelect;
			}

			return select;
		}
开发者ID:mattleibow,项目名称:Mono.Data.Sqlite.Orm.Linq,代码行数:45,代码来源:SkipToRowNumberRewriter.cs

示例2: BindAnyAll

 private Expression BindAnyAll(Expression source, MethodInfo method, LambdaExpression predicate, bool isRoot)
 {
     bool isAll = method.Name == "All";
     ConstantExpression constSource = source as ConstantExpression;
     if (constSource != null && !IsQuery(constSource))
     {
         System.Diagnostics.Debug.Assert(!isRoot);
         Expression where = null;
         foreach (object value in (IEnumerable)constSource.Value)
         {
             Expression expr = Expression.Invoke(predicate, Expression.Constant(value, predicate.Parameters[0].Type));
             if (where == null)
             {
                 where = expr;
             }
             else if (isAll)
             {
                 where = where.And(expr);
             }
             else
             {
                 where = where.Or(expr);
             }
         }
         return this.Visit(where);
     }
     else
     {
         if (isAll)
         {
             predicate = Expression.Lambda(Expression.Not(predicate.Body), predicate.Parameters.ToArray());
         }
         if (predicate != null)
         {
             source = Expression.Call(typeof(Enumerable), "Where", method.GetGenericArguments(), source, predicate);
         }
         ProjectionExpression projection = this.VisitSequence(source);
         Expression result = new ExistsExpression(projection.Select);
         if (isAll)
         {
             result = Expression.Not(result);
         }
         if (isRoot)
         {
             if (this.language.AllowSubqueryInSelectWithoutFrom)
             {
                 return GetSingletonSequence(result, "SingleOrDefault");
             }
             else
             {
                 // use count aggregate instead of exists
                 var colType = this.language.TypeSystem.GetColumnType(typeof(int));
                 var newSelect = projection.Select.SetColumns(
                     new[] { new ColumnDeclaration("value", new AggregateExpression(typeof(int), "Count", null, false), colType) }
                     );
                 var colx = new ColumnExpression(typeof(int), colType, newSelect.Alias, "value");
                 var exp = isAll
                     ? colx.Equal(Expression.Constant(0))
                     : colx.GreaterThan(Expression.Constant(0));
                 return new ProjectionExpression(
                     newSelect, exp, Aggregator.GetAggregator(typeof(bool), typeof(IEnumerable<bool>))
                     );
             }
         }
         return result;
     }
 }
开发者ID:RukaiYu,项目名称:EnterpriseDevelopmentFx,代码行数:67,代码来源:QueryBinder.cs


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