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


C# Expressions.Expression类代码示例

本文整理汇总了C#中System.Linq.Expressions.Expression的典型用法代码示例。如果您正苦于以下问题:C# Expression类的具体用法?C# Expression怎么用?C# Expression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Expression类属于System.Linq.Expressions命名空间,在下文中一共展示了Expression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CompileBulkImporter

        public override Expression CompileBulkImporter(EnumStorage enumStorage, Expression writer, ParameterExpression document, ParameterExpression alias, ParameterExpression serializer)
        {
            var method = writeMethod.MakeGenericMethod(typeof(string));
            var dbType = Expression.Constant(DbType);

            return Expression.Call(writer, method, alias, dbType);
        }
开发者ID:danielmarbach,项目名称:marten,代码行数:7,代码来源:DocTypeArgument.cs

示例2: Visit

        protected override Expression Visit(Expression exp)
        {
            if(exp != null)
                return base.Visit(exp);

            return exp;
        }
开发者ID:kccarter,项目名称:SubSonic-3.0,代码行数:7,代码来源:QueryVisitor.cs

示例3: CanBeEvaluatedLocally

        // private static methods
        private static Boolean CanBeEvaluatedLocally(Expression expression, IQueryProvider queryProvider)
        {
            // any operation on a query can't be done locally
            var constantExpression = expression as ConstantExpression;
            if (constantExpression != null)
            {
                var query = constantExpression.Value as IQueryable;
                if (query != null && (queryProvider == null || query.Provider == queryProvider))
                {
                    return false;
                }
            }

            var methodCallExpression = expression as MethodCallExpression;
            if (methodCallExpression != null)
            {
                Type declaringType = methodCallExpression.Method.DeclaringType;
                if (declaringType == typeof (Enumerable) || declaringType == typeof (Queryable))
                {
                    return false;
                }
            }

            if (expression.NodeType == ExpressionType.Convert && expression.Type == typeof (Object))
            {
                return true;
            }

            if (expression.NodeType == ExpressionType.Parameter || expression.NodeType == ExpressionType.Lambda)
            {
                return false;
            }

            return true;
        }
开发者ID:sprucemedia,项目名称:oinq,代码行数:36,代码来源:PartialEvaluator.cs

示例4: Binding

 internal Binding(Expression linqExpression, DbExpression cqtExpression)
 {
     //Contract.Requires(linqExpression != null);
     //Contract.Requires(cqtExpression != null);
     LinqExpression = linqExpression;
     CqtExpression = cqtExpression;
 }
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:Binding.cs

示例5: ExpressionToString

        public static string ExpressionToString(Expression expr)
        {
            if (propertyDebugView == null)
                propertyDebugView = typeof(Expression).GetTypeInfo().FindDeclaredProperty("DebugView", ReflectionFlag.NoException | ReflectionFlag.NonPublic | ReflectionFlag.Instance);

            return (string)propertyDebugView.GetValue(expr, null);
        }
开发者ID:strogo,项目名称:neolua,代码行数:7,代码来源:Parser.cs

示例6: GetDocumentType

        // private static methods
        private static Type GetDocumentType(Expression expression)
        {
            // look for the innermost nested constant of type MongoQueryable<T> and return typeof(T)
            var constantExpression = expression as ConstantExpression;
            if (constantExpression != null)
            {
                var constantType = constantExpression.Type;
                if (constantType.IsGenericType)
                {
                    var genericTypeDefinition = constantType.GetGenericTypeDefinition();
                    if (genericTypeDefinition == typeof(MongoQueryable<>))
                    {
                        return constantType.GetGenericArguments()[0];
                    }
                }
            }

            var methodCallExpression = expression as MethodCallExpression;
            if (methodCallExpression != null && methodCallExpression.Arguments.Count != 0)
            {
                return GetDocumentType(methodCallExpression.Arguments[0]);
            }

            var message = string.Format("Unable to find document type of expression: {0}.", ExpressionFormatter.ToString(expression));
            throw new ArgumentOutOfRangeException(message);
        }
开发者ID:newlee,项目名称:mongo-csharp-driver,代码行数:27,代码来源:MongoQueryTranslator.cs

示例7: Gather

 private void Gather(Expression expression)
 {
     BinaryExpression b = expression as BinaryExpression;
     if (b != null)
     {
         switch (b.NodeType)
         {
             case ExpressionType.Equal:
             case ExpressionType.NotEqual:
                 if (IsExternalColumn(b.Left) && GetColumn(b.Right) != null)
                 {
                     this.columns.Add(GetColumn(b.Right));
                 }
                 else if (IsExternalColumn(b.Right) && GetColumn(b.Left) != null)
                 {
                     this.columns.Add(GetColumn(b.Left));
                 }
                 break;
             case ExpressionType.And:
             case ExpressionType.AndAlso:
                 if (b.Type == typeof(bool) || b.Type == typeof(bool?))
                 {
                     this.Gather(b.Left);
                     this.Gather(b.Right);
                 }
                 break;
         }
     }
 }
开发者ID:CMONO,项目名称:elinq,代码行数:29,代码来源:JoinColumnGatherer.cs

示例8: Get

 public IEnumerable<ErrorLog> Get(
    Expression<Func<ErrorLog, bool>> filter = null,
    Func<IQueryable<ErrorLog>, IOrderedQueryable<ErrorLog>> orderBy = null,
    string includeProperties = "")
 {
     return _unitOfWork.ErrorLogRepository.Get(filter, orderBy, includeProperties);
 }
开发者ID:edgecomputing,项目名称:cats,代码行数:7,代码来源:ErrorLogService.cs

示例9: CreateSetFieldExpression

        internal static Expression CreateSetFieldExpression(Expression clone, Expression value, FieldInfo fieldInfo) {
            // workaround for readonly fields: use reflection, this is a lot slower but the only way except using il directly
            if (fieldInfo.IsInitOnly)
                return Expression.Call(Expression.Constant(fieldInfo), _fieldInfoSetValueMethod, clone, Expression.Convert(value, TypeHelper.ObjectType));

            return Expression.Assign(Expression.Field(clone, fieldInfo), value);
        }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:7,代码来源:CloneExpressionHelper.cs

示例10: VisitExpression

		public override Expression VisitExpression(Expression expression)
		{
			if (expression == null)
			{
				return null;
			}

			switch ((NhExpressionType)expression.NodeType)
			{
				case NhExpressionType.Average:
				case NhExpressionType.Min:
				case NhExpressionType.Max:
				case NhExpressionType.Sum:
				case NhExpressionType.Count:
				case NhExpressionType.Distinct:
					return VisitNhAggregate((NhAggregatedExpression)expression);
				case NhExpressionType.New:
					return VisitNhNew((NhNewExpression)expression);
				case NhExpressionType.Star:
					return VisitNhStar((NhStarExpression)expression);
			}

			// Keep this variable for easy examination during debug.
			var expr = base.VisitExpression(expression);
			return expr;
		}
开发者ID:jlevitt,项目名称:nhibernate-core,代码行数:26,代码来源:NhExpressionTreeVisitor.cs

示例11: UnaryExpression

 internal UnaryExpression(ExpressionType nodeType, Expression expression, Type type, MethodInfo method)
 {
     _operand = expression;
     _method = method;
     _nodeType = nodeType;
     _type = type;
 }
开发者ID:mesheets,项目名称:Theraot-CF,代码行数:7,代码来源:UnaryExpression.net30.cs

示例12: PrettyPrint

 // public methods
 /// <summary>
 /// Pretty prints an Expression.
 /// </summary>
 /// <param name="node">The Expression to pretty print.</param>
 /// <returns>A string containing the pretty printed Expression.</returns>
 public string PrettyPrint(Expression node)
 {
     _sb = new StringBuilder();
     _indentation = "";
     Visit(node);
     return _sb.ToString();
 }
开发者ID:mpobrien,项目名称:mongo-csharp-driver,代码行数:13,代码来源:ExpressionPrettyPrinter.cs

示例13: CreatePropertyAccessExpression

        private Expression CreatePropertyAccessExpression(Expression instance, string propertyName)
        {
            CallSiteBinder binder = Binder.GetMember(CSharpBinderFlags.None, propertyName,
                typeof(DynamicPropertyAccessExpressionBuilder), new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) });

            return Expression.Dynamic(binder, typeof(object), new[] { instance });
        }
开发者ID:akhuang,项目名称:Asp.net-MVC-3,代码行数:7,代码来源:DynamicPropertyAccessExpressionBuilder.cs

示例14: EvaluateUnsupported

		EvaluationResult EvaluateUnsupported(Expression expression) {
			try {
				return EvaluationResult.Success(expression.Type, Expression.Lambda<Func<object>>(expression.Box()).Compile()());
			} catch(Exception e) {
				return EvaluationResult.Failure(expression, e);
			}
		}
开发者ID:drunkcod,项目名称:Cone,代码行数:7,代码来源:ExpressionEvaluator.cs

示例15: BuildExpression

			public override Expression BuildExpression(Expression expression, int level)
			{
				var expr = Sequence.BuildExpression(expression, level);

				if (expression == null)
				{
					var q =
						from col in SqlQuery.Select.Columns
						where !col.CanBeNull()
						select SqlQuery.Select.Columns.IndexOf(col);

					var idx = q.DefaultIfEmpty(-1).First();

					if (idx == -1)
						idx = SqlQuery.Select.Add(new SqlValue((int?) 1));

					var n = ConvertToParentIndex(idx, this);

					var e = Expression.Call(
						ExpressionBuilder.DataReaderParam,
						ReflectionHelper.DataReader.IsDBNull,
						Expression.Constant(n)) as Expression;

					var defaultValue = _defaultValue ?? Expression.Constant(null, expr.Type);

					expr = Expression.Condition(e, defaultValue, expr);
				}

				return expr;
			}
开发者ID:x64,项目名称:bltoolkit,代码行数:30,代码来源:DefaultIfEmptyBuilder.cs


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