本文整理汇总了C#中AnonymousTypeCreateExpression.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# AnonymousTypeCreateExpression.Clone方法的具体用法?C# AnonymousTypeCreateExpression.Clone怎么用?C# AnonymousTypeCreateExpression.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnonymousTypeCreateExpression
的用法示例。
在下文中一共展示了AnonymousTypeCreateExpression.Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildExpression
public string BuildExpression(Dictionary<string, Expression> selectExpressions)
{
var anonymousTypeCreateExpression = new AnonymousTypeCreateExpression();
var crrv = new ChangeRootReferenceVisitor(FromIdentifier);
foreach (var curExpr in selectExpressions.OrderBy(x => x.Key))
{
curExpr.Value.AcceptVisitor(crrv);
anonymousTypeCreateExpression.Initializers.Add(
new AssignmentExpression(new IdentifierExpression(curExpr.Key), curExpr.Value.Clone()));
}
if (FromExpression == null)
FromExpression = new IdentifierExpression();
var queryExpr = new QueryExpression
{
Clauses =
{
new QueryFromClause
{
Identifier = "doc",
Expression = FromExpression.Clone()
},
new QuerySelectClause
{
Expression = anonymousTypeCreateExpression.Clone()
}
}
};
FromIdentifier = "doc";
var printer = new StringWriter();
var printerVisitor = new CSharpOutputVisitor(printer, FormattingOptionsFactory.CreateSharpDevelop());
queryExpr.AcceptVisitor(printerVisitor);
var format = printer.GetStringBuilder().ToString();
if (format.Substring(0, 3) == "\r\n\t")
{
format = format.Remove(0, 3);
}
format = format.Replace("\r\n\t", "\n");
return format;
}