本文整理汇总了C#中AstNode.Invert方法的典型用法代码示例。如果您正苦于以下问题:C# AstNode.Invert方法的具体用法?C# AstNode.Invert怎么用?C# AstNode.Invert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AstNode
的用法示例。
在下文中一共展示了AstNode.Invert方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandMacro
public override BuiltinExpansion ExpandMacro(OracularConfig config, OracularTable parent, OracularTable child, Reference reference, AstNode nestedSpec)
{
var withTable = String.Format ("Annotated{0}{1}", parent.Table, nestedSpec.Id);
var relationship = child.GetRelationshipTo (parent.Table);
if (relationship == null)
{
var message = String.Format ("unable to find relationship from {0} to {1}", child.Table, parent.Table);
throw new OracularException (message);
}
var mainJoin = String.Format ("LEFT JOIN [{0}] ON [{0}].[{1}] = [{2}].[{3}]",
withTable,
parent.Id,
parent.Table,
parent.Id
);
var macroField = String.Format ("{0}{1}{2}", Name, child.Table, nestedSpec.Id);
var builder = new Sqlizer (child, config);
var nestedWhere = nestedSpec == null ? "" : String.Format("\nWHERE {0}",
(invertNested ? nestedSpec.Invert() : nestedSpec).Walk(builder)
);
var nestedJoins = builder.JoinTables.Count() == 0 ? "" : "\n" + String.Join("\n",
builder.JoinTables
);
var nestedQuery = String.Format (@"[{0}] AS (
SELECT DISTINCT [{1}].[{2}], 1 [{3}]
FROM [{1}]
LEFT JOIN [{4}] ON [{4}].[{5}] = [{1}].[{2}]{6}{7}
)", withTable, parent.Table, parent.Id, macroField, child.Table, relationship.Id, nestedJoins, nestedWhere);
var expansion = new BuiltinExpansion ();
expansion.With.AddRange (builder.CommonTableExpressions);
expansion.With.Add (nestedQuery);
expansion.Join.Add (mainJoin);
expansion.Where = String.Format ("[{0}].[{1}]{2}", withTable, macroField, suffix);
return expansion;
}