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


C# Expression.StripQuotes方法代码示例

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


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

示例1: GetFieldRef

		public static XElement GetFieldRef(ISpModelContext modelContext, Expression node)
		{
			if (node == null)
			{
				throw new ArgumentNullException("node");
			}

			node = node.StripQuotes();

			if (node.NodeType != ExpressionType.MemberAccess)
			{
				throw new NotSupportedException(string.Format("{0} should be a member access", node));
			}

			var memberExpression = (MemberExpression) node;
			var memberName = memberExpression.Member.Name;

			if (memberExpression.Expression.NodeType != ExpressionType.Parameter)
			{
				throw new NotSupportedException(string.Format("{0} not supported", memberExpression));
			}

			return new XElement(Tags.FieldRef,
				new XAttribute(Tags.Name, modelContext.GetSpFieldInternalName(memberExpression.Member.DeclaringType, memberName)));
		}
开发者ID:s-KaiNet,项目名称:Untech.SharePoint,代码行数:25,代码来源:TranslatorHelpers.cs

示例2: UpdateSelect

        public ProjectionExpression UpdateSelect(ProjectionExpression projection, Expression selectExpression)
        {
            //get the lambda expression of the select method
            var lambda = (LambdaExpression)selectExpression.StripQuotes();

            //if the lambda, is the identity lamda, simply return
            if (lambda.IsIdentityLambda())
                return projection;

            //map the source argument of the lambda expression to the existing projection
            Map.Add(lambda.Parameters[0], projection.Projection);

            //get the new projection
            var newProjection = Visit(lambda.Body);

            //check if projection is actually changed
            if (newProjection == lambda.Body)
                return projection;

            //get used columns
            IEnumerable<SelectorExpression> columns = new ColumnFinder().FindColumns(newProjection);

            SelectStatementExpression select = projection.Select;
            var newSelect = new SelectStatementExpression(typeof(IEnumerable<>).MakeGenericType(newProjection.Type),
                                                          new SelectClauseExpression(columns.ToArray(),
                                                                                     select.SelectClause.Distinct),
                                                          select.TableName,
                                                          select.WhereClause,
                                                          select.OrderBy,
                                                          select.Limit,
                                                          select.AllowFiltering);
            
            return new ProjectionExpression(newSelect, newProjection, projection.Aggregator, false, projection.Consistency, projection.PageSize);
        }
开发者ID:reuzel,项目名称:CqlSharp.Linq,代码行数:34,代码来源:SelectBuilder.cs

示例3: BuildWhere

        public ProjectionExpression BuildWhere(ProjectionExpression projection, Expression whereClause)
        {
            //get the lambda expression of the select method
            var lambda = (LambdaExpression)whereClause.StripQuotes();

            //map the source argument of the lambda expression to the existing projection (the projection is what the where clause queries)
            Map.Add(lambda.Parameters[0], projection.Projection);

            if (projection.Select.WhereClause != null)
                _relations = new HashSet<RelationExpression>(projection.Select.WhereClause);
            else
                _relations = new HashSet<RelationExpression>();

            //get the new projections
            Expression expression = Visit(lambda.Body);

            if (!expression.IsTrue())
                throw new CqlLinqException("Where clause contains unsupported constructs");

            var select = projection.Select;

            var newSelectStmt = new SelectStatementExpression(select.Type,
                                                              select.SelectClause,
                                                              select.TableName,
                                                              _relations.ToArray(),
                                                              select.OrderBy,
                                                              select.Limit,
                                                              select.AllowFiltering);

            return new ProjectionExpression(newSelectStmt, projection.Projection,
                                            projection.Aggregator, projection.CanTrackChanges, projection.Consistency, projection.PageSize);
        }
开发者ID:reuzel,项目名称:CqlSharp.Linq,代码行数:32,代码来源:WhereBuilder.cs

示例4: VisitLimit

		private XElement VisitLimit(Expression node)
		{
			node = node.StripQuotes();

			if (node.NodeType != ExpressionType.Constant)
			{
				throw new NotSupportedException(string.Format("Limit {0} not supported", node));
			}

			var constExpression = (ConstantExpression) node;

			return new XElement(Tags.RowLimit, constExpression.Value);
		}
开发者ID:s-KaiNet,项目名称:Untech.SharePoint,代码行数:13,代码来源:LimitTranslator.cs

示例5: GetValue

		public static XElement GetValue(ISpModelContext modelContext, MemberExpression memberExpression, Expression node)
		{
			if (node == null)
			{
				throw new ArgumentNullException("node");
			}

			node = node.StripQuotes();

			if (node.NodeType != ExpressionType.Constant)
			{
				throw new NotSupportedException(string.Format("{0} should be a constant expression", node));
			}

			var constantExpression = (ConstantExpression)node;

			return new XElement(Tags.Value, 
				new XAttribute(Tags.Type, modelContext.GetSpFieldTypeAsString(memberExpression.Member.DeclaringType, memberExpression.Member.Name)),
				Convert.ToString(modelContext.ConvertToSpValue(memberExpression.Member.DeclaringType, memberExpression.Member.Name, constantExpression.Value)));
		}
开发者ID:s-KaiNet,项目名称:Untech.SharePoint,代码行数:20,代码来源:TranslatorHelpers.cs

示例6: UpdateOrder

        public ProjectionExpression UpdateOrder(ProjectionExpression projection, Expression keySelectExpression,
                                                bool ascending)
        {
            //get the lambda expression of the select method
            var lambda = (LambdaExpression)keySelectExpression.StripQuotes();

            //map the source argument of the lambda expression to the existing projection
            Map.Add(lambda.Parameters[0], projection.Projection);

            //get the new projection
            var key = Visit(lambda.Body);

            //check if we are dealing with a column
            if ((CqlExpressionType)key.NodeType != CqlExpressionType.IdentifierSelector)
                throw new CqlLinqException("Select key in OrderBy does not map to table column");

            //get a reference to the select clause
            SelectStatementExpression select = projection.Select;

            //add the ordering to the list of orderBy clauses
            var ordering = new List<OrderingExpression>(select.OrderBy);
            ordering.Add(new OrderingExpression((SelectorExpression)key,
                                                ascending
                                                    ? CqlExpressionType.OrderAscending
                                                    : CqlExpressionType.OrderDescending));

            var newSelect = new SelectStatementExpression(select.Type,
                                                          select.SelectClause,
                                                          select.TableName,
                                                          select.WhereClause,
                                                          ordering,
                                                          select.Limit,
                                                          select.AllowFiltering);

            return new ProjectionExpression(newSelect, projection.Projection,
                                            projection.Aggregator, projection.CanTrackChanges, projection.Consistency, projection.PageSize);
        }
开发者ID:reuzel,项目名称:CqlSharp.Linq,代码行数:37,代码来源:OrderBuilder.cs

示例7: GetDistinctColumns

		private IEnumerable<Expression> GetDistinctColumns(Expression expression)
		{
			var destType = expression.Type;
			if (!destType.IsComplexType())
				return new Expression[] { expression };

			var columns = DistinctColumnExtractor.GetDistinctColumns(mapper, expression.StripQuotes());

			columns = columns.Select(c => this.Visit(c)).ToList();

			return columns;
		}
开发者ID:viceroypenguin,项目名称:Complete.Data,代码行数:12,代码来源:QueryBinder.cs

示例8: VisitSourceReferencedProjection

		protected LambdaExpression VisitSourceReferencedProjection(FromExpression from, Expression expression)
		{
			fromExpressions.Push(from);
			var projection = this.Visit(PartialEvaluator.Eval(expression.StripQuotes())) as LambdaExpression;
			fromExpressions.Pop();
			return projection;
		}
开发者ID:viceroypenguin,项目名称:Complete.Data,代码行数:7,代码来源:QueryBinder.cs


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