コード例 #1
0
        private void initSqlHelper(string _providerName)
        {
            _cacheService    = new MemoryCacheService();
            _events          = new SqlEvents();
            _tableNameManger = new TableNameManger();
            _sqlConfig       = new SqlConfig(this);
            _sql             = new SqlRecord();
            _sqlMonitor      = new NullSqlMonitor();
            _sql.SqlMonitor  = _sqlMonitor;


            _connectionType = ConnectionType.Default;

            if (_providerName != null)
            {
                _sqlType = SqlConfig.GetSqlType(_providerName, _writeConnectionString);
                var _provider = DatabaseProvider.Resolve(_sqlType);
                _factory = _provider.GetFactory();
            }
            else
            {
                _sqlType = SqlConfig.GetSqlType(_factory.GetType().FullName, _writeConnectionString);
            }

            _provider = DatabaseProvider.Resolve(_sqlType);
        }
コード例 #2
0
        private void initSqlHelper(string connectionString, string providerName)
        {
            _lastConnectionString = connectionString;
            _lastProviderName     = providerName;

            _connectionString = connectionString;
            var txts = connectionString.Split(';');

            foreach (var txt in txts)
            {
                var sp = txt.Split('=');
                if (sp.Length != 2)
                {
                    continue;
                }
                if (sp[0].ToLower() == "database")
                {
                    _schemaName = sp[1];
                    break;
                }
                if (sp[0].ToLower() == "data source")
                {
                    _schemaName = sp[1];
                    break;
                }
            }


            _cacheService = new MemoryCacheService();
            _events       = new SqlEvents();
            _sqlConfig    = new SqlConfig(this);
            _sql          = new SqlRecord();
            _sqlMonitor   = new NullSqlMonitor();


            if (_sqlType == SqlType.None)
            {
                _sqlType = DatabaseProvider.GetSqlType(providerName ?? _factory.GetType().FullName, _connectionString);
            }
            _provider = DatabaseProvider.Resolve(_sqlType);
            if (_factory == null)
            {
                _factory     = _provider.GetFactory();
                _lastFactory = _factory;
            }
            if (_lastSqlHelper == null || _lastSqlHelper._isDisposable)
            {
                _lastSqlHelper = this;
            }
        }