本文整理汇总了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));
}
示例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);
}
}
示例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;
}
示例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();
}
示例5: VisitWhere
protected override void VisitWhere(Expressions.IWhereExpression expression)
{
if (clauseText.Length != 0)
{
clauseText.Append("AND ");
}
base.VisitWhere(expression);
}
示例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();
}
示例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;
}
示例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);
}
示例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 },
});
}
示例10: Visit
public virtual void Visit(Expressions.VoidInitializer x)
{
}