本文整理汇总了C#中ExpressionBuilder.BuildSequence方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionBuilder.BuildSequence方法的具体用法?C# ExpressionBuilder.BuildSequence怎么用?C# ExpressionBuilder.BuildSequence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExpressionBuilder
的用法示例。
在下文中一共展示了ExpressionBuilder.BuildSequence方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var query = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[1], new SqlQuery()));
var except = query.SqlQuery;
sequence = new SubQueryContext(sequence);
var sql = sequence.SqlQuery;
except.ParentSql = sql;
if (methodCall.Method.Name == "Except")
sql.Where.Not.Exists(except);
else
sql.Where.Exists(except);
var keys1 = sequence.ConvertToSql(null, 0, ConvertFlags.Key);
var keys2 = query. ConvertToSql(null, 0, ConvertFlags.Key);
if (keys1.Length != keys2.Length)
throw new InvalidOperationException();
for (var i = 0; i < keys1.Length; i++)
{
except.Where
.Expr(keys1[i].Sql)
.Equal
.Expr(keys2[i].Sql);
}
return sequence;
}
示例2: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
if (sequence.SelectQuery.Select.TakeValue != null || sequence.SelectQuery.Select.SkipValue != null)
sequence = new SubQueryContext(sequence);
var lambda = (LambdaExpression)methodCall.Arguments[1].Unwrap();
var sparent = sequence.Parent;
var order = new ExpressionContext(buildInfo.Parent, sequence, lambda);
var body = lambda.Body.Unwrap();
var sql = builder.ConvertExpressions(order, body, ConvertFlags.Key);
builder.ReplaceParent(order, sparent);
if (!methodCall.Method.Name.StartsWith("Then"))
sequence.SelectQuery.OrderBy.Items.Clear();
foreach (var expr in sql)
{
var e = builder.ConvertSearchCondition(sequence, expr.Sql);
sequence.SelectQuery.OrderBy.Expr(e, methodCall.Method.Name.EndsWith("Descending"));
}
return sequence;
}
示例3: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var condition = (LambdaExpression)methodCall.Arguments[1].Unwrap();
var result = builder.BuildWhere(buildInfo.Parent, sequence, condition, true);
result.SetAlias(condition.Parameters[0].Name);
return result;
}
示例4: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var sql = sequence.SqlQuery;
if (sql.Select.TakeValue != null || sql.Select.SkipValue != null)
sequence = new SubQueryContext(sequence);
sequence.SqlQuery.Select.IsDistinct = true;
sequence.ConvertToIndex(null, 0, ConvertFlags.All);
return sequence;
}
示例5: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var table = (TableBuilder.TableContext)sequence;
var selector = (LambdaExpression)methodCall.Arguments[1].Unwrap();
if (table.SqlTable.LoadWith == null)
table.SqlTable.LoadWith = new List<MemberInfo[]>();
table.SqlTable.LoadWith.Add(GetAssosiations(builder, selector.Body.Unwrap()).ToArray());
return sequence;
}
示例6: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var table = (TableBuilder.TableContext)sequence;
var value = (string)((ConstantExpression)methodCall.Arguments[1]).Value;
switch (methodCall.Method.Name)
{
case "TableName" : table.SqlTable.PhysicalName = value; break;
case "DatabaseName" : table.SqlTable.Database = value; break;
case "OwnerName" : table.SqlTable.Owner = value; break;
}
return sequence;
}
示例7: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var table = (TableBuilder.TableContext)sequence;
var value = (string)((ConstantExpression)methodCall.Arguments[1]).Value;
table.SqlTable.SqlTableType = SqlTableType.Expression;
table.SqlTable.TableArguments = new ISqlExpression[0];
switch (methodCall.Method.Name)
{
case "With" : table.SqlTable.Name = "{{0}} {{1}} WITH ({0})".Args(value); break;
case "WithTableExpression" : table.SqlTable.Name = value; break;
}
return sequence;
}
示例8: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var defaultValue = methodCall.Arguments.Count == 1 ? null : methodCall.Arguments[1].Unwrap();
if (buildInfo.Parent is SelectManyBuilder.SelectManyContext)
{
var groupJoin = ((SelectManyBuilder.SelectManyContext)buildInfo.Parent).Sequence[0] as JoinBuilder.GroupJoinContext;
if (groupJoin != null)
{
groupJoin.SelectQuery.From.Tables[0].Joins[0].JoinType = SelectQuery.JoinType.Left;
groupJoin.SelectQuery.From.Tables[0].Joins[0].IsWeak = false;
}
}
return new DefaultIfEmptyContext(buildInfo.Parent, sequence, defaultValue);
}
示例9: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
var sequence = builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
var arg = methodCall.Arguments[1].Unwrap();
if (arg.NodeType == ExpressionType.Lambda)
arg = ((LambdaExpression)arg).Body.Unwrap();
var expr = builder.ConvertToSql(sequence, arg);
if (methodCall.Method.Name == "Take")
{
BuildTake(builder, sequence, expr);
}
else
{
BuildSkip(builder, sequence, sequence.SqlQuery.Select.SkipValue, expr);
}
return sequence;
}
示例10: BuildMethodCall
protected override IBuildContext BuildMethodCall(ExpressionBuilder builder, MethodCallExpression methodCall, BuildInfo buildInfo)
{
return builder.BuildSequence(new BuildInfo(buildInfo, methodCall.Arguments[0]));
}