Пример #1
0
 public void MysqlFindByID()
 {
     //mysql FindByID
     MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
     UserLocalDAL userLocalDAL = new UserLocalDAL();
     var          result       = userLocalDAL.FindByID(2);
 }
Пример #2
0
 public void MysqlExecute()
 {
     MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
     UserLocalDAL userLocalDAL = new UserLocalDAL();
     var          commandText  = $"update {EntityHelper.CallName<UserLocal>()} set status = 7 where id > 30";
     var          result       = userLocalDAL.Execute(commandText, null);
 }
Пример #3
0
 public void MysqlDelete()
 {
     MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
     UserLocalDAL userLocalDAL = new UserLocalDAL();
     var          result       = userLocalDAL.Delete(new UserLocal {
         ID = 13
     });
 }
Пример #4
0
        public void CreateConnectionMysqlFact()
        {
            //mysql 创建连接
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            ConnectionFactory connectionFactory = new ConnectionFactory();
            IDbConnection     dbConnection      = connectionFactory.CreateConnection();

            dbConnection.Open();
        }
Пример #5
0
        public void CreateConnectionOracleFact()
        {
            //oracle 创建连接
            MyDapperPower.DbConnection("Data Source=192.168.1.75/pdb2;User ID=itps_test;PassWord=mysql", "oracle", "oracel");
            ConnectionFactory connectionFactory = new ConnectionFactory();
            IDbConnection     dbConnection      = connectionFactory.CreateConnection();

            dbConnection.Open();
        }
Пример #6
0
 public void MysqlUpdate()
 {
     MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
     UserLocalDAL userLocalDAL = new UserLocalDAL();
     //ID id必须填写,否则修改失败
     var result = userLocalDAL.Update(new UserLocal {
         ID = 8, Password = "******", UserName = "******", PickName = "2", MobilePhone = "2", Status = 2
     });
 }
Пример #7
0
 public void MysqlInsert()
 {
     //mysql Insert
     MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
     UserLocalDAL userLocalDAL = new UserLocalDAL();
     var          result       = userLocalDAL.Insert(new UserLocal {
         Password = "******", UserName = "******", PickName = "1", MobilePhone = "1", Status = 1
     });
 }
Пример #8
0
        public void MysqlExecuteScalar()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();
            var          commandText  = $"select * from {EntityHelper.CallName<UserLocal>()} where id = @id";
            int          id           = 21;
            var          result       = userLocalDAL.ExecuteScalar <int>(commandText, new { id });

            Assert.Equal(id, result);
        }
Пример #9
0
        public void MysqlFindByIDTra()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();

            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = userLocalDAL.Connection)
                {
                    var result = userLocalDAL.FindByID(connection, 2);
                }
            }
        }
Пример #10
0
        public void MysqlUpdateList()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL      userLocalDAL  = new UserLocalDAL();
            IList <UserLocal> userLocalList = new List <UserLocal>();

            for (int i = 8; i < 14; i++)
            {
                userLocalList.Add(new UserLocal {
                    ID = i, Password = "******", UserName = "******", PickName = "3", MobilePhone = "3", Status = 3
                });
            }
            var result = userLocalDAL.Update(userLocalList);
        }
Пример #11
0
        public void MysqlExecuteTra()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();
            var          commandText  = $"update {EntityHelper.CallName<UserLocal>()} set status = 7 where id > 30";

            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = userLocalDAL.Connection)
                {
                    var result = userLocalDAL.Execute(connection, commandText, null);
                }
            }
        }
Пример #12
0
        public void MysqlDeleteList()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL      userLocalDAL  = new UserLocalDAL();
            IList <UserLocal> userLocalList = new List <UserLocal>();

            for (int i = 8; i < 20; i++)
            {
                userLocalList.Add(new UserLocal {
                    ID = i
                });
            }
            var result = userLocalDAL.Delete(userLocalList);
        }
Пример #13
0
        public void MysqlUpdateTra()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();

            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = userLocalDAL.Connection)
                {
                    var result = userLocalDAL.Update(connection, new UserLocal {
                        ID = 26, Password = "******", UserName = "******", PickName = "2", MobilePhone = "2", Status = 2
                    });
                }
            }
        }
Пример #14
0
        public void MysqlExecuteScalarTra()
        {
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL userLocalDAL = new UserLocalDAL();
            var          commandText  = $"select status from {EntityHelper.CallName<UserLocal>()} where id = @id";
            var          commandText2 = $"update {EntityHelper.CallName<UserLocal>()} set status = 5 where id = @id";

            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = userLocalDAL.Connection)
                {
                    int id      = 22;
                    var result1 = userLocalDAL.ExecuteScalar <int>(connection, commandText2, new { id });
                    var result2 = userLocalDAL.ExecuteScalar <int>(connection, commandText, new { id });
                    Assert.Equal(5, result2);
                }
            }
        }
Пример #15
0
        public void MysqlInsertListTra()
        {
            // 事务不能insert数据,需要修改bug
            MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
            UserLocalDAL      userLocalDAL  = new UserLocalDAL();
            IList <UserLocal> userLocalList = new List <UserLocal>();

            for (int i = 0; i < 5; i++)
            {
                userLocalList.Add(new UserLocal {
                    Password = "******", UserName = "******", PickName = "2", MobilePhone = "2", Status = 2
                });
            }
            using (var transactionScope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                using (var connection = userLocalDAL.Connection)
                {
                    var result = userLocalDAL.Insert(connection, userLocalList);
                }
            }
        }
Пример #16
0
 public void DbConnectionMysqlFact()
 {
     //mysql 配置测试
     MyDapperPower.DbConnection("server=localhost;port=3306;user id=root;password=Aa82078542;database=testmysql;SslMode=none", "mysql", "mysql");
 }
Пример #17
0
 public void DbConnectionOracleFact()
 {
     //oracle 配置测试
     MyDapperPower.DbConnection("Data Source=192.168.1.75/pdb2;User ID=itps_test;PassWord=mysql", "oracle", "oracel");
 }