static void TalkToPG() { var table = new PGTable("northwindPG", "products", "productid"); var list = table.All(); foreach (var p in list) { Console.WriteLine(p.productid); } }
static bool TableExists(string tableName) { bool exists = false; string select = "" + "SELECT * FROM INFORMATION_SCHEMA.TABLES " + "WHERE TABLE_SCHEMA = 'dbo' " + "AND TABLE_NAME = '{0}'"; string sql = string.Format(select, tableName); var Model = new PGTable<dynamic>(_connectionStringName); var query = Model.Query<dynamic>(sql); if (query.Count() > 0) { exists = true; } return exists; }
static void DropTable(string tableName) { string sql = string.Format("DROP TABLE {0}", tableName); var Model = new PGTable<dynamic>(_connectionStringName); Model.Execute(sql); }
bool TableExists(string tableName) { bool exists = false; string select = "" + "SELECT * FROM information_schema.tables " + "WHERE table_schema = 'public' " + "AND table_name = '{0}'"; string sql = string.Format(select, tableName); var Model = new PGTable<dynamic>(_connectionStringName); var query = Model.Query<dynamic>(sql); if (query.Count() > 0) { exists = true; } return exists; }
static void CreateClientsTable() { string sql = "" + "CREATE TABLE clients " + "(client_Id serial NOT NULL, " + "last_name Text NOT NULL, " + "first_name Text NOT NULL, " + "email Text NOT NULL, " + "CONSTRAINT client_pkey PRIMARY KEY (client_Id))"; var Model = new PGTable<Client>(_connectionStringName); Model.Execute(sql); }
void CreateWTFTable() { string sql = "" + "CREATE TABLE wtf " + "(\"CLient_Id\" serial NOT NULL, " + "\"Last Name\" Text NOT NULL, " + "\"first_name\" Text NOT NULL, " + "\"Email\" Text NOT NULL, " + "CONSTRAINT wtf_pkey PRIMARY KEY (\"CLient_Id\"))"; var Model = new PGTable<dynamic>(_connectionStringName); Model.Execute(sql); }