當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。