C# Class BF2Statistics.Database.QueryBuilder.InsertQueryBuilder

Provides an object interface that can properly put together an Insert Query string.
All parameters in the WHERE and HAVING statements will be escaped by the underlaying DbCommand object, making the Execute*() methods SQL injection safe.
Show file Open project: BF2Statistics/ControlCenter Class Usage Examples

Public Properties

Property Type Description
Table string

Protected Properties

Property Type Description
Driver DatabaseDriver
Fields object>.Dictionary

Public Methods

Method Description
BuildCommand ( ) : DbCommand

Builds the query string with the current SQL Statement, and returns the DbCommand to be executed. All WHERE paramenters are propery escaped, making this command SQL Injection safe.

BuildQuery ( ) : string

Builds the query string with the current SQL Statement, and returns the querystring. This method is NOT Sql Injection safe!

Execute ( ) : int

Executes the built SQL statement on the Database connection that was passed in the contructor. All WHERE paramenters are propery escaped, making this command SQL Injection safe.

InsertQueryBuilder ( DatabaseDriver Driver ) : System

Creates a new instance of InsertQueryBuilder with the provided Database Driver.

InsertQueryBuilder ( string Table, DatabaseDriver Driver ) : System

Creates a new instance of InsertQueryBuilder with the provided Database Driver.

SetDbDriver ( DatabaseDriver Driver ) : void

Sets the database driver

SetField ( string Field, object Value ) : void

Sets a value for the specified field

SetTable ( string Table ) : void

Sets the table name to inesrt into

Protected Methods

Method Description
BuildQuery ( bool BuildCommand ) : object

Builds the query string or DbCommand

Method Details

BuildCommand() public method

Builds the query string with the current SQL Statement, and returns the DbCommand to be executed. All WHERE paramenters are propery escaped, making this command SQL Injection safe.
public BuildCommand ( ) : DbCommand
return System.Data.Common.DbCommand

BuildQuery() protected method

Builds the query string or DbCommand
protected BuildQuery ( bool BuildCommand ) : object
BuildCommand bool
return object

BuildQuery() public method

Builds the query string with the current SQL Statement, and returns the querystring. This method is NOT Sql Injection safe!
public BuildQuery ( ) : string
return string

Execute() public method

Executes the built SQL statement on the Database connection that was passed in the contructor. All WHERE paramenters are propery escaped, making this command SQL Injection safe.
public Execute ( ) : int
return int

InsertQueryBuilder() public method

Creates a new instance of InsertQueryBuilder with the provided Database Driver.
public InsertQueryBuilder ( DatabaseDriver Driver ) : System
Driver DatabaseDriver The DatabaseDriver that will be used to query this SQL statement
return System

InsertQueryBuilder() public method

Creates a new instance of InsertQueryBuilder with the provided Database Driver.
public InsertQueryBuilder ( string Table, DatabaseDriver Driver ) : System
Table string The table we are inserting into
Driver DatabaseDriver The DatabaseDriver that will be used to query this SQL statement
return System

SetDbDriver() public method

Sets the database driver
public SetDbDriver ( DatabaseDriver Driver ) : void
Driver DatabaseDriver
return void

SetField() public method

Sets a value for the specified field
public SetField ( string Field, object Value ) : void
Field string The column or field name
Value object The value to insert
return void

SetTable() public method

Sets the table name to inesrt into
public SetTable ( string Table ) : void
Table string The name of the table to insert into
return void

Property Details

Driver protected property

The database driver, if using the "BuildCommand" method
protected DatabaseDriver Driver
return DatabaseDriver

Fields protected property

A list of FieldValuePairs
protected Dictionary Fields
return object>.Dictionary

Table public property

The table name to query
public string Table
return string