DotNetSqlGenerator.Library.DbProviders.PostgreSQL.PgSqlGenerator.cs

PostgreSQL specific generator

PgSqlGenerator : SqlGenerator, IGenerator

PgSqlGenerator(string connectionString)
PgSqlGenerator(string ip, int port, string username, string password, string database, [optional]string options)
Details:
  • Handles all database interaction for PostgreSQL
  • Loads table names on initialization

Properties

public IEnumerable<string> TableNames { get; private set; }
 new protected NpgsqlConnection Connection;

Usage

PgSqlGenerator pg = new PgSqlGenerator("127.0.0.1", 5432, "postgres", "sql", "testing");
Table T1 = pg.GetTable("test");
Table T2 = pg.GetTable("different_table");

QueryInformation insertT1 = pg.ExecuteInsert(T1);
QueryInformation insertT2 = pg.ExecuteInsert(T2);

QueryInformation deleteT2 = pg.ExecuteDelete(T2);
QueryInformation updateT1 = pg.ExecuteUpdate(T1);
QueryInformation selectT1 = pg.ExecuteSelect(T1);

Methods

int RunNonQuery
  • Operates just like a regular ExecuteNonquery, except it only takes in a sSQL statement (string)
public int RunNonQuery(string query)

IDataReader RunReader
  • Operates just like a regular ExecuteReader, except it only takes in a sSQL statement (string)
public IDataReader RunReader(string query)

object RunScalar
  • Operates just like a regular ExecuteScalar, except it only takes in a sSQL statement (string)
public object RunScalar(string query)

QueryInformation ExecuteInsert
public QueryInformation ExecuteInsert(Table T)

QueryInformation ExecuteBulkInsert
public QueryInformation ExecuteBulkInsert(Table T, int howMany)

QueryInformation ExecuteDelete
  • Generates a random delete for a Table, executes it, and records the results in a QueryInformation object
  • Guaranteed to delete at least one record
public QueryInformation ExecuteDelete(Table T)

QueryInformation ExecuteUpdate
  • Generates a random update for a Table, executes it, and records the results in a QueryInformation object
  • Guaranteed to update at least one record
public QueryInformation ExecuteUpdate(Table T)

QueryInformation ExecuteSelect
  • Generates a random select for a Table, executes it, and records the results in a QueryInformation object
  • Guaranteed to select at least one record
  • The number of columns to search and/or return can be specified
public QueryInformation ExecuteSelect(Table T, [optional]int columnsToReturn, [optional]int columnsToSearch)

Last edited Dec 3, 2010 at 7:06 PM by naspinski, version 10

Comments

No comments yet.