//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()); }
public static HashSet <T> ExtractNodes <T>(IDmlfNode node) where T : class, IDmlfNode { var res = new HashSet <T>(); ExtractNodes(node, res); return(res); }
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()); }
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); } }); }