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


C# Expressions类代码示例

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


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

示例1: Generate

 public override string Generate(Expressions.RenameTableExpression expression)
 {
     return string.Format(
         "RENAME TABLE {0} TO {1}",
         this.QuoteSchemaAndTable(expression.SchemaName, expression.OldName),
         Quoter.QuoteTableName(expression.NewName));
 }
开发者ID:akema-fr,项目名称:fluentmigrator,代码行数:7,代码来源:Db2Generator.cs

示例2: VisitAndAlso

        protected override void VisitAndAlso(Expressions.AndAlsoExpression expression)
        {
            string leftClause = "";
            if (!(expression.Left is TrueExpression))
            {
                leftClause = VisitInner(expression.Left).ClauseText;
            }

            string rightClause = "";
            if (!(expression.Right is TrueExpression))
            {
                rightClause = VisitInner(expression.Right).ClauseText;
            }

            if (!string.IsNullOrEmpty(leftClause) && !string.IsNullOrEmpty(rightClause))
            {
                clauseText.AppendFormat("(({0}) AND ({1}))", leftClause, rightClause);
            }
            else if (!string.IsNullOrEmpty(leftClause))
            {
                clauseText.Append(leftClause);
            }
            else if (!string.IsNullOrEmpty(rightClause))
            {
                clauseText.Append(rightClause);
            }
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:27,代码来源:StringVisitor.cs

示例3: VisitMethodDefinitionExpression

        protected override Expression VisitMethodDefinitionExpression(Expressions.MethodDefinitionExpression method)
        {
            this.containsDateConversion = false;

            var retval = (MethodDefinitionExpression)base.VisitMethodDefinitionExpression(method);

            if (this.containsDateConversion && retval.Body is BlockExpression)
            {
                var block = (BlockExpression)retval.Body;
                var variables = new List<ParameterExpression>(block.Variables);
                var dateFormatter = Expression.Variable(new FickleType("NSDateFormatter"), "dateFormatter");
                variables.Add(dateFormatter);
                var expressions = new List<Expression>();

                // dateFormatter = [[NSDateFormatter alloc]init]
                expressions.Add(Expression.Assign(dateFormatter, Expression.New(new FickleType("NSDateFormatter"))).ToStatement());
                // [dateFormatter setTimeZone: [NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
                expressions.Add(FickleExpression.Call(dateFormatter, "setTimeZone", FickleExpression.StaticCall("NSTimeZone", "NSTimeZone", "timeZoneWithAbbreviation", "UTC")).ToStatement());
                // [dateFormatter setDateFormat: @"yyyy-MM-dd'T'HH:mm:ssZZZZZ"];
                expressions.Add(FickleExpression.Call(dateFormatter, "setDateFormat", "yyyy-MM-dd'T'HH:mm:ssZZZZZ").ToStatement());

                expressions.AddRange(block.Expressions);

                var newBody = Expression.Block(variables, expressions);

                return new MethodDefinitionExpression(retval.Name, retval.Parameters, retval.ReturnType, newBody, retval.IsPredeclaration, retval.RawAttributes);
            }

            return retval;
        }
开发者ID:techpub,项目名称:Fickle,代码行数:30,代码来源:DateFormatterInserter.cs

示例4: Generate

        public override string Generate(Expressions.DeleteSequenceExpression expression)
        {
            var result = new StringBuilder(string.Format("DROP SEQUENCE "));
            result.AppendFormat("{0}.{1}", Quoter.QuoteSchemaName(expression.SchemaName), Quoter.QuoteSequenceName(expression.SequenceName));

            return result.ToString();
        }
开发者ID:reharik,项目名称:fluentmigrator,代码行数:7,代码来源:SqlServer2012Generator.cs

示例5: VisitWhere

 protected override void VisitWhere(Expressions.IWhereExpression expression)
 {
     if (clauseText.Length != 0)
     {
         clauseText.Append("AND ");
     }
     base.VisitWhere(expression);
 }
开发者ID:Godoy,项目名称:CMS,代码行数:8,代码来源:StringVisitor.cs

示例6: Visite

        public override void Visite(Expressions.IExpression expression)
        {
            selectText = "*";
            clauseText = new StringBuilder();
            sortText = new StringBuilder();

            base.Visite(expression);

            query.SelectText = selectText.ToString();
            query.ClauseText = clauseText.ToString();
            query.SortText = sortText.ToString();
        }
开发者ID:Epitomy,项目名称:CMS,代码行数:12,代码来源:StringVisitor.cs

示例7: ConvertExpressionToConstant

        /// <summary>
        /// Converts the expression to constant.
        /// </summary>
        private string ConvertExpressionToConstant(Expressions.BindingPathExpression expression, string propertyName)
        {
            if (expression is BindingConstantExpression)
            {
                return ((BindingConstantExpression)expression).Value;
            }

            if (!(expression is BindingGetPropertyExpression) || ((BindingGetPropertyExpression)expression).NextExpression != null)
            {
                ThrowParserError(string.Format("The value of property '{0}' must be one word and must not contain other characters than letters, numbers or underscore. Otherwise the value must be in enclosed in double quotes.", propertyName));
            }

            return ((BindingGetPropertyExpression)expression).PropertyName;
        }
开发者ID:jechtom,项目名称:Redwood,代码行数:17,代码来源:BindingParser.cs

示例8: Bind

        public override Expression Bind(Expressions.ProjectionExpression projection, ProjectionBindingContext context, System.Linq.Expressions.MethodCallExpression node, IEnumerable<System.Linq.Expressions.Expression> arguments)
        {
            var aggregatorName = "Single";
            var returnType = node.Method.ReturnType;
            if (node.Method.Name.EndsWith("Async"))
            {
                aggregatorName += "Async";
                returnType = returnType.GetGenericArguments()[0];
            }

            var aggregator = CreateAggregator(aggregatorName, returnType);

            var source = projection.Source;
            var argument = arguments.FirstOrDefault();
            if (argument != null && ExtensionExpressionVisitor.IsLambda(argument))
            {
                var lambda = ExtensionExpressionVisitor.GetLambda(argument);
                var binder = new AccumulatorBinder(context.GroupMap, context.SerializerRegistry);
                binder.RegisterParameterReplacement(lambda.Parameters[0], projection.Projector);
                argument = binder.Bind(lambda.Body);
            }
            else
            {
                argument = projection.Projector;
                var select = source as SelectExpression;
                if (select != null)
                {
                    source = select.Source;
                }
            }

            var serializer = context.SerializerRegistry.GetSerializer(returnType);
            var accumulator = new AccumulatorExpression(returnType, AccumulatorType, argument);
            var serializationAccumulator = new SerializationExpression(
                accumulator,
                new BsonSerializationInfo("__agg0", serializer, serializer.ValueType));

            var rootAccumulator = new RootAccumulatorExpression(source, serializationAccumulator);

            return new ProjectionExpression(
                rootAccumulator,
                serializationAccumulator,
                aggregator);
        }
开发者ID:kay-kim,项目名称:mongo-csharp-driver,代码行数:44,代码来源:RootAccumulatorBinderBase.cs

示例9: Test1

        public void Test1()
        {
            var exps = new Expressions();

            var query = Db<DB>.Sql(db =>
                Select(Asterisk(db.tbl_staff)).
                From(db.tbl_staff).
                Where(exps.Condition1 || exps.Condition2));

            var datas = _connection.Query(query).ToList();
            Assert.IsTrue(0 < datas.Count);
            AssertEx.AreEqual(query, _connection,
@"SELECT *
FROM tbl_staff
WHERE ((@val1) = (@p_0)) OR ((@val1) = (@p_1))", 
new Params()
{
    { "@val1", 1 },
    { "@p_0", 1 },
    { "@p_1", 2 },
});
        }
开发者ID:Codeer-Software,项目名称:LambdicSql,代码行数:22,代码来源:TestParameterName.cs

示例10: Visit

		public virtual void Visit(Expressions.VoidInitializer x)
		{
			
		}
开发者ID:DinrusGroup,项目名称:DinrusIDE,代码行数:4,代码来源:DefaultDepthFirstVisitor.cs


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