예제 #1
0
        //public static List<string> GetBaseColumns(this IEnumerable<DmlfColumnRef> cols)
        //{
        //    var res = new List<string>();
        //    foreach (var col in cols)
        //    {
        //        if (col.Source != null && col.Source.Alias != "basetbl") continue;
        //        res.Add(col.ColumnName);
        //    }
        //    return res;
        //}

        //public static int GetBaseOrdinal(this IEnumerable<DmlfColumnRef> cols, string colname)
        //{
        //    int index = 0;
        //    foreach (var col in cols)
        //    {
        //        if (col.Source == null || col.Source.Alias == "basetbl")
        //        {
        //            if (col.ColumnName == colname) return index;
        //        }
        //        index++;
        //    }
        //    return -1;
        //}

        public static string ToSql(this IDmlfNode node, ISqlDialect dialect, IDmlfHandler handler)
        {
            var sw  = new StringWriter();
            var dmp = dialect.CreateDumper(sw);

            node.GenSql(dmp, handler);
            return(sw.ToString());
        }
예제 #2
0
        public static HashSet <T> ExtractNodes <T>(IDmlfNode node)
            where T : class, IDmlfNode
        {
            var res = new HashSet <T>();

            ExtractNodes(node, res);
            return(res);
        }
예제 #3
0
        public static string ToSql(this IDmlfNode node, IDatabaseFactory factory)
        {
            if (factory == null)
            {
                return("");
            }
            var sw  = new StringWriter();
            var dmp = factory.CreateDumper(new SqlOutputStream(factory.CreateDialect(), sw, SqlFormatProperties.Default), SqlFormatProperties.Default);

            node.GenSql(dmp);
            return(sw.ToString());
        }
예제 #4
0
 private static void ExtractNodes <T>(IDmlfNode node, HashSet <T> res)
     where T : class, IDmlfNode
 {
     node.ForEachChild(child =>
     {
         var add = child as T;
         if (add != null)
         {
             res.Add(add);
         }
     });
 }