Ejemplo n.º 1
0
        public IFreeSql Build()
        {
            IFreeSql ret = null;

            switch (_dataType)
            {
            case DataType.MySql: ret = new MySql.MySqlProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.SqlServer: ret = new SqlServer.SqlServerProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.PostgreSQL: ret = new PostgreSQL.PostgreSQLProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.Oracle: ret = new Oracle.OracleProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.Sqlite: ret = new Sqlite.SqliteProvider(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;
            }
            if (ret != null)
            {
                ret.CodeFirst.IsAutoSyncStructure = _isAutoSyncStructure;

                ret.CodeFirst.IsSyncStructureToLower = _isSyncStructureToLower;
                ret.CodeFirst.IsSyncStructureToUpper = _isSyncStructureToUpper;
                ret.CodeFirst.IsLazyLoading          = _isLazyLoading;
                var ado = ret.Ado as Internal.CommonProvider.AdoProvider;
                ado.AopCommandExecuting += _aopCommandExecuting;
                ado.AopCommandExecuted  += _aopCommandExecuted;
            }
            return(ret);
        }
Ejemplo n.º 2
0
        public IFreeSql <TMark> Build <TMark>()
        {
            IFreeSql <TMark> ret = null;

            switch (_dataType)
            {
            case DataType.MySql: ret = new MySql.MySqlProvider <TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.SqlServer: ret = new SqlServer.SqlServerProvider <TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.PostgreSQL: ret = new PostgreSQL.PostgreSQLProvider <TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.Oracle: ret = new Oracle.OracleProvider <TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            case DataType.Sqlite: ret = new Sqlite.SqliteProvider <TMark>(_cache, _logger, _masterConnectionString, _slaveConnectionString); break;

            default: throw new Exception("未指定 UseConnectionString");
            }
            if (ret != null)
            {
                ret.CodeFirst.IsAutoSyncStructure = _isAutoSyncStructure;

                ret.CodeFirst.IsSyncStructureToLower    = _isSyncStructureToLower;
                ret.CodeFirst.IsSyncStructureToUpper    = _isSyncStructureToUpper;
                ret.CodeFirst.IsConfigEntityFromDbFirst = _isConfigEntityFromDbFirst;
                ret.CodeFirst.IsNoneCommandParameter    = _isNoneCommandParameter;
                ret.CodeFirst.IsLazyLoading             = _isLazyLoading;
                var ado = ret.Ado as Internal.CommonProvider.AdoProvider;
                ado.AopCommandExecuting += _aopCommandExecuting;
                ado.AopCommandExecuted  += _aopCommandExecuted;
            }
            return(ret);
        }