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


C# AstNode.Invert方法代码示例

本文整理汇总了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;
        }
开发者ID:couchand,项目名称:oracular-dot-net,代码行数:47,代码来源:Builtins.cs


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