This project is read-only.

DotNetSqlGenerator.Library.GenerateSql.cs

Generic factory for SQL strings

GenerateSql

public GenerateSql()

Properties

public Type[] UnQuotedTypes = new Type[] { typeof(bool) };
public GenerateValues GenerateValue;
public Random Rand;
!!Usage
PgSqlGenerator pg = new PgSqlGenerator("127.0.0.1", 5432, "postgres", "sql", "testing");
Table T = pg.GetTable("test");

// use it standalone
GenerateSql generate = new GenerateSql();
string delete = generate.Delete(T);
string update = generate.Update(T, pg);

// use it in a PgSqlGenerator:
string insert = pg.Generate.Insert(T);
string bulkInsert = pg.Generate.BulkInsert(T, 100);

Methods

Delete
  • Creates a random delete string for Table T
  • Requires an initialized PgSqlGenerator pg
  • Guaranteed to be a delete of at least one record in the table
public string Delete(Table T, PgSqlGenerator pg)

Update
  • Creates a random update string for Table T
  • Requires an initialized PgSqlGenerator pg
  • Guaranteed to be an update of at least one record in the table
public string Update(Table T, PgSqlGenerator pg)

Select
  • Creates a random select string for Table T
  • Requires an initialized PgSqlGenerator pg
  • Guaranteed to be a select of at least one record in the table
  • Number of 'select' and 'where' columns to have in the query can be specified
public string Select(Table T, PgSqlGenerator pg, [optional]int numberOfColumnsToReturn, [optional]int numberOfColumnsToSearch)

Insert
  • Create a random insert string for Table T
public string Insert(Table T)

Inserts
  • Create a many random insert string for Table T
  • This does not return a string, but an IEnumerable collection of length howMany
public IEnumerable<string> Inserts(Table T, int howMany)

BulkInsert
  • Create a random bulk insert string for Table T
  • Inserts howMany records into the table
public string BulkInsert(Table T, int howMany)

Last edited Dec 3, 2010 at 6:56 PM by naspinski, version 6

Comments

No comments yet.