コード例 #1
0
        private IDbConnection GetOpenConnection()
        {
            IDbConnection connection;

            if (_dbtype == DapperCRUD.Dialect.PostgreSQL)
            {
                connection = new NpgsqlConnection(String.Format("Server={0};Port={1};User Id={2};Password={3};Database={4};", "localhost", "5432", "postgres", "postgrespass", "testdb"));
                DapperCRUD.SetDialect(DapperCRUD.Dialect.PostgreSQL);
            }
            else if (_dbtype == DapperCRUD.Dialect.SQLite)
            {
                connection = new SQLiteConnection("Data Source=MyDatabase.sqlite;Version=3;");
                DapperCRUD.SetDialect(DapperCRUD.Dialect.SQLite);
            }
            else if (_dbtype == DapperCRUD.Dialect.MySQL)
            {
                connection = new MySqlConnection(String.Format("Server={0};Port={1};User Id={2};Password={3};Database={4};", "localhost", "3306", "admin", "admin", "testdb"));
                DapperCRUD.SetDialect(DapperCRUD.Dialect.MySQL);
            }
            else
            {
                connection = new SqlConnection(@"Data Source = (LocalDB)\v11.0;Initial Catalog=DapperDapperCRUDTestDb;Integrated Security=True;MultipleActiveResultSets=true;");
                DapperCRUD.SetDialect(DapperCRUD.Dialect.SQLServer);
            }

            connection.Open();
            return(connection);
        }
コード例 #2
0
        //dialect test

        public void TestChangeDialect()
        {
            DapperCRUD.SetDialect(DapperCRUD.Dialect.SQLServer);
            DapperCRUD.GetDialect().IsEqualTo(DapperCRUD.Dialect.SQLServer.ToString());
            DapperCRUD.SetDialect(DapperCRUD.Dialect.PostgreSQL);
            DapperCRUD.GetDialect().IsEqualTo(DapperCRUD.Dialect.PostgreSQL.ToString());
        }
コード例 #3
0
 public TestDapperCRUD()
 {
     dapperCrud = new DapperCRUD();
 }