C# Class Azavea.NijPredictivePolicing.Common.DB.DataClient

Generic helper class for managing database connections and objects
Datei anzeigen Open project: azavea/acs-alchemist

Public Methods

Method Description
GenerateTableSQLFromFields ( string tablename, List columns ) : string

Convenience function to generate SQL to create a table matching the provided fields

GetDefaultClient ( string hostname ) : IDataClient

Get an instance of the default overridding database type

GetMagicAdapter ( DbConnection conn, IDataClient client, string sql ) : DbDataAdapter

Uses a select statement and the ADO.NET CommandBuilder to generate Insert,Update, and Delete statements, and load them onto an adapter

GetMagicTable ( DbConnection conn, IDataClient client, string sql ) : DataTable

'Magically' populates a DataTable object with the contents of your sql query

HasColumn ( string columnname, string tablename, DbConnection conn, IDataClient client ) : bool

Returns true if a particular table has a particular column

HasTable ( DbConnection conn, IDataClient client, string tablename ) : bool

Checks the schema of the database to see if the given table is present

RowCount ( DbConnection conn, IDataClient client, string tablename ) : int

Method Details

GenerateTableSQLFromFields() public static method

Convenience function to generate SQL to create a table matching the provided fields
public static GenerateTableSQLFromFields ( string tablename, List columns ) : string
tablename string the name for the new table
columns List a collection of FixedWidthField objects
return string

GetDefaultClient() public static method

Get an instance of the default overridding database type
public static GetDefaultClient ( string hostname ) : IDataClient
hostname string
return IDataClient

GetMagicAdapter() public static method

Uses a select statement and the ADO.NET CommandBuilder to generate Insert,Update, and Delete statements, and load them onto an adapter
public static GetMagicAdapter ( DbConnection conn, IDataClient client, string sql ) : DbDataAdapter
conn System.Data.Common.DbConnection
client IDataClient
sql string
return System.Data.Common.DbDataAdapter

GetMagicTable() public static method

'Magically' populates a DataTable object with the contents of your sql query
public static GetMagicTable ( DbConnection conn, IDataClient client, string sql ) : DataTable
conn System.Data.Common.DbConnection
client IDataClient
sql string
return System.Data.DataTable

HasColumn() public static method

Returns true if a particular table has a particular column
public static HasColumn ( string columnname, string tablename, DbConnection conn, IDataClient client ) : bool
columnname string
tablename string
conn System.Data.Common.DbConnection
client IDataClient
return bool

HasTable() public static method

Checks the schema of the database to see if the given table is present
public static HasTable ( DbConnection conn, IDataClient client, string tablename ) : bool
conn System.Data.Common.DbConnection
client IDataClient
tablename string
return bool

RowCount() public static method

public static RowCount ( DbConnection conn, IDataClient client, string tablename ) : int
conn System.Data.Common.DbConnection
client IDataClient
tablename string
return int