Beispiel #1
0
        public static void GenerateInsertFixedData(ITableSource table, TextWriter tw, ISqlDialect dialect)
        {
            ITableStructure ts  = table.LoadTableStructure(TableStructureMembers.All);
            ISqlDumper      dmp = dialect.CreateDumper(tw);

            GenerateInsertFixedData(dmp, ts);
        }
Beispiel #2
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());
        }
Beispiel #3
0
 public virtual void OpenFile()
 {
     if (m_fw != null)
     {
         return;
     }
     m_fw = new StreamWriter(FileName);
     m_formatProps.DumpWriterConfig = Config;
     GetFormatProps(m_formatProps);
     //if (m_formatProps.DumpFileBegin != null) m_fw.Write(m_formatProps.DumpFileBegin);
     m_dmp = m_dialect.CreateDumper(m_fw, m_formatProps);
     WriteHeader();
 }
Beispiel #4
0
        public static string GenerateScript(this ISqlDialect dialect, Action <ISqlDumper> script, SqlFormatProperties props)
        {
            StringWriter sw = new StringWriter();
            ISqlDumper   dmp;

            if (dialect != null)
            {
                dmp = dialect.CreateDumper(sw, props);
            }
            else
            {
                dialect = new GenericDialect();
                dmp     = new InfoSqlDumper(new SqlOutputStream(dialect, sw, props), dialect, props);
            }
            script(dmp);
            return(sw.ToString());
        }
Beispiel #5
0
        private void DoRefreshPreview()
        {
            var sw  = new StringWriter();
            var dmp = m_dialect.CreateDumper(sw, m_formatProps);

            if (m_sqlgen is IAppObjectSqlGenerator)
            {
                foreach (var obj in m_objs)
                {
                    if (m_db != null)
                    {
                        ((IAppObjectSqlGenerator)m_sqlgen).GenerateSql(m_db, obj.GetFullDatabaseRelatedName(), dmp, m_dialect);
                    }
                    else
                    {
                        ((IAppObjectSqlGenerator)m_sqlgen).GenerateSql(obj, dmp, m_dialect);
                    }
                }
            }
            if (m_sqlgen is IDataSqlGenerator)
            {
                if (((IDataSqlGenerator)m_sqlgen).IsRowEnumerator)
                {
                    var preview  = m_rowsExtractor.GetPreviewRows(m_previewRows);
                    int rowcount = m_rowsExtractor.GetRowCount();

                    dmp.Put("-- All row count: %s, preview row count: %s\n\n", rowcount, preview.Rows.Count);
                    foreach (var row in preview.Rows)
                    {
                        ((IDataSqlGenerator)m_sqlgen).GenerateSqlRow(row, dmp, m_dataFrame.GetSelectedColumns());
                    }
                }
                else
                {
                    ((IDataSqlGenerator)m_sqlgen).GenerateSql(dmp);
                }
            }
            m_preview = sw.ToString();
        }
Beispiel #6
0
        public void CreateDatabase(IDatabaseSource db, TextWriter tw, ISqlDialect dialect)
        {
            ISqlDumper dmp = dialect.CreateDumper(tw);

            dmp.CreateDatabase(db.DatabaseName, null);
        }
Beispiel #7
0
        public void CreateReferences(IDatabaseSource conn, TextWriter tw, ISqlDialect dialect)
        {
            ISqlDumper dmp = dialect.CreateDumper(tw);

            CreateReferences(conn, dmp, dialect);
        }
Beispiel #8
0
        public void CreateSpecificObjects(IDatabaseSource conn, TextWriter tw, ISqlDialect dialect)
        {
            ISqlDumper dmp = dialect.CreateDumper(tw);

            CreateSpecificObjects(conn, dmp, dialect);
        }
Beispiel #9
0
        public static ISqlDumper CreateDumper(this ISqlDialect dialect, TextWriter tw, SqlFormatProperties props)
        {
            SqlOutputStream sqlo = new SqlOutputStream(dialect, tw, props);

            return(dialect.CreateDumper(sqlo, props));
        }
Beispiel #10
0
 public virtual ISqlDumper CreateDumper(ISqlOutputStream stream, SqlFormatProperties props)
 {
     return(m_dialect.CreateDumper(stream, props));
 }