コード例 #1
0
        /// <summary>
        ///     Accepts a ISqlWritable object, and write its Backup into the StreamWriter
        /// </summary>
        /// <param name="source"></param>
        /// <param name="includeDropSql"></param>
        /// <param name="includeData"></param>
        public void WriteSqlContent(ISqlWritable source, bool includeDropSql = true, bool includeData = true)
        {
            // Write header and dropSql (if requested only)
            _streamWriter.WriteLine(Common.GenerateHeader(source.GetType(), source.ToString()));
            if (includeDropSql)
            {
                _streamWriter.WriteLine(source.GetDropSql() + "\r\n");
            }

            // Write Ddl
            _streamWriter.WriteLine(source.GetDdl().Trim(';', '\r', '\n') + ";");

            // If source is a table and includeData = true, back up data too
            if (source is Table table && includeData)
            {
                // Initialize table column details
                table.Columns = _dbReader.GetTableColumnDetails(table.Name);
                using (var reader = _dbReader.GetTableDataReader(table))
                {
                    WriteTableData(table, reader);
                }
            }

            // Insert New Line
            _streamWriter.WriteLine();
        }
コード例 #2
0
 public void R(ISqlWritable writable) => this.R(p => writable);
コード例 #3
0
 public void M(ISqlWritable writable) => this.M(p => writable);