示例#1
0
        //private IDbTransaction _transaction;

        public BaseRepository(string dbName)
        {
            _entityInfo = EntityInfo <TEntity> .Create();

            if (dbName.IsEmpty())
            {
                throw new Exception(nameof(dbName));
            }
            _connectionInfo = ConnectionStringInfo.GetConnectionByName(dbName);
            if (_connectionInfo == null)
            {
                throw new Exception("Can not get connection info");
            }

            _connection = new MySqlConnection(_connectionInfo.Value);
            _connection.EnsureOpen();
            //_transaction = _connection.BeginTransaction();
        }
示例#2
0
        public static void InitTest()
        {
            var _connectionInfo = ConnectionStringInfo.GetConnectionByName("db_kinta");

            if (_connectionInfo == null)
            {
                throw new Exception("Can not get connection info");
            }

            var con = new MySqlConnection(_connectionInfo.Value);

            con.EnsureOpen();
            using (con)
            {
                using (var ts = con.BeginTransaction())
                {
                }
            }
            //con.state = close after run out of using
        }