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


C# IDatabaseFactory.CreateDialect方法代码示例

本文整理汇总了C#中IDatabaseFactory.CreateDialect方法的典型用法代码示例。如果您正苦于以下问题:C# IDatabaseFactory.CreateDialect方法的具体用法?C# IDatabaseFactory.CreateDialect怎么用?C# IDatabaseFactory.CreateDialect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDatabaseFactory的用法示例。


在下文中一共展示了IDatabaseFactory.CreateDialect方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SqlDumper

 public SqlDumper(ISqlOutputStream stream, IDatabaseFactory factory, SqlFormatProperties props)
 {
     m_stream = stream;
     m_props = props;
     m_factory = factory;
     m_DDA = m_factory.CreateDataAdapter();
     m_formatterState.DDA = m_DDA;
     m_dialect = m_factory.CreateDialect();
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:9,代码来源:SqlDumper.cs

示例2: SqlScriptCompiler

        public SqlScriptCompiler(IDatabaseFactory factory, DataSyncSqlModel datasync, IShellContext context, string procName)
        {
            _context = context;
            _procName = procName;
            _datasync = datasync;
            _factory = factory;

            _sw = new StringWriter();
            var so = new SqlOutputStream(factory.CreateDialect(), _sw, new SqlFormatProperties());
            so.OverrideCommandDelimiter(";");
            _dmp = factory.CreateDumper(so, new SqlFormatProperties());
        }
开发者ID:dbshell,项目名称:dbshell,代码行数:12,代码来源:SqlScriptCompiler.cs

示例3: Format

        public static string Format(IDatabaseFactory factory, SqlFormatProperties props, SqlFormatterState state, string format, params object[] args)
        {
            IDialectDataAdapter dda = null;
            if (state != null) dda = state.DDA;
            if (dda == null) dda = factory.CreateDataAdapter();
            var dialect = factory.CreateDialect();

            int argindex = 0;
            StringBuilder sb = new StringBuilder();
            int i = 0;
            while (i < format.Length)
            {
                char c = format[i];
                switch (c)
                {
                    case '^': // SQL keyword
                        {
                            i++;
                            DumpSeparatorIfNeeded(sb, props, state);
                            while (i < format.Length && (Char.IsLetter(format, i) || format[i] == '_'))
                            {
                                sb.Append(GetCasedChar(format[i], props.SqlCommandCase));
                                i++;
                            }
                            DataDumped(state);
                        }
                        break;
                    case '&': // indentation & spacing
                        {
                            i++;
                            c = format[i];
                            i++;
                            char level = '0';
                            if (c == '1' || c == '2' || c == '3' || c == '5')
                            {
                                level = c;
                                c = format[i];
                                i++;
                            }
                            if (level != '0')
                            {
                                // indentation levels
                                if (props.IndentationLevel == SqlIndentationLevel.Original || props.IndentationLevel == SqlIndentationLevel.SingleLine)
                                {
                                    if (c == 'n' || c == 's')
                                    {
                                        if (state != null)
                                        {
                                            state.SeparatorNeeded = true;
                                        }
                                        else
                                        {
                                            sb.Append(" ");
                                        }
                                    }
                                    // when original indentation is used, don't use our separators
                                    break;
                                }
                                bool valid = (props.IndentationLevel == SqlIndentationLevel.Compact && (level == '2' || level == '5'))
                                    || (props.IndentationLevel == SqlIndentationLevel.Large && (level == '3' || level == '5'));
                                if (!valid)
                                {
                                    break; // mark is not for this indentation level
                                }
                            }
                            switch (c)
                            {
                                case '&':
                                    sb.Append("&");
                                    break;
                                case 'n':
                                    if (state == null) DumpEoln(sb, props, state);
                                    else state.LineFeedNeeded = true;
                                    break;
                                case '>':
                                    if (state != null) state.IndentLevel++;
                                    break;
                                case '<':
                                    if (state != null) state.IndentLevel--;
                                    break;
                                case 's':
                                    if (state != null) state.SeparatorNeeded = true;
                                    else sb.Append(" ");
                                    break;
                                case 'r':
                                    DumpSeparatorIfNeeded(sb, props, state);
                                    break;
                                case 'd':
                                    DataDumped(state);
                                    break;
                                default:
                                    throw new InternalError("DBSH-00042 Unknown & formatting instruction:" + c);
                            }
                        }
                        break;
                    case '%': // format parameter
                        {
                            i++;
                            c = format[i];

//.........这里部分代码省略.........
开发者ID:dbshell,项目名称:dbshell,代码行数:101,代码来源:SqlDumper_FmtUtils.cs

示例4: GenerateSql

 public static string GenerateSql(IDatabaseFactory factory, Action<ISqlDumper> func)
 {
     var sw = new StringWriter();
     var so = new SqlOutputStream(factory.CreateDialect(), sw, new SqlFormatProperties());
     var dmp = factory.CreateDumper(so, new SqlFormatProperties());
     func(dmp);
     return sw.ToString();
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:8,代码来源:SqlDumper_FmtUtils.cs

示例5: ToSql

 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();
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:8,代码来源:DmlfExtension.cs

示例6: LiteralFormatterBase

 public LiteralFormatterBase(IDatabaseFactory factory)
 {
     _factory = factory;
     _dialect = _factory.CreateDialect();
 }
开发者ID:dbshell,项目名称:dbshell,代码行数:5,代码来源:LiteralFormatterBase.cs

示例7: FreeExternalSources

        private void FreeExternalSources(DbConnection conn, IDatabaseFactory factory, IShellContext context)
        {
            if (!_externalSources.Any()) return;

            var sw = new StringWriter();
            var so = new ConnectionSqlOutputStream(conn, null, factory.CreateDialect());
            var dmp = factory.CreateDumper(so, new SqlFormatProperties());

            foreach (var exSource in _externalSources)
            {
                var tbl = new TableInfo(null) { FullName = exSource.ExternalDataName };
                dmp.DropTable(tbl, false);
            }
        }
开发者ID:dbshell,项目名称:dbshell,代码行数:14,代码来源:DataSyncSqlModel.cs

示例8: FillExternalSources

        private void FillExternalSources(DbConnection conn, IDatabaseFactory factory, IShellContext context)
        {
            if (!_externalSources.Any()) return;

            var sw = new StringWriter();
            var so = new ConnectionSqlOutputStream(conn, null, factory.CreateDialect());
            var dmp = factory.CreateDumper(so, new SqlFormatProperties());

            foreach (var exSource in _externalSources)
            {
                var tbl = new TableInfo(null) { FullName = exSource.ExternalDataName };
                foreach (var col in exSource.Dbsh.Columns)
                {
                    tbl.Columns.Add(new ColumnInfo(tbl)
                    {
                        Name = col.Name,
                        DataType = col.DataType ?? "nvarchar(500)",
                        CommonType = DbTypeBase.ParseType(col.DataType ?? "nvarchar(500)"),
                    });
                }
                dmp.CreateTable(tbl);

                var filterModel = FilterJoinSqlModel.Create(exSource, SourceGraphModel, factory);

                var copyTable = new DbShell.Core.CopyTable
                {
                    Source = filterModel?.DataSource ?? exSource.Dbsh.DataSource,
                    Target = new DbShell.Core.Table
                    {
                        Name = exSource.ExternalDataName.Name,
                        StructureOverride = tbl,
                    },
                    AllowBulkCopy = _model.AllowBulkCopy,
                };
                var runnable = (IRunnable)copyTable;
                runnable.Run(context);

                if (exSource.Dbsh.OnExternalFilledAssertion != null)
                {
                    string value = conn.ExecuteScalar(exSource.Dbsh.OnExternalFilledAssertion.Replace("${TABLE}", exSource.ExternalDataName.Name))?.ToString();
                    if (value != exSource.Dbsh.OnExternalFilledRequiredValue)
                    {
                        throw new Exception($"DBSH-00000 OnExternalFilledAssertion failed, source={exSource.SqlAlias}, required={exSource.Dbsh.OnExternalFilledRequiredValue}, actual={value}, query={exSource.Dbsh.OnExternalFilledAssertion}");
                    }
                }
            }
        }
开发者ID:dbshell,项目名称:dbshell,代码行数:47,代码来源:DataSyncSqlModel.cs


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