C# Class Azavea.Open.DAO.SQL.AbstractSqlConnectionDescriptor

This class represents the information needed to establish a connection to a data source that speaks SQL (presumably a database). This class, and any that extend it, should be thread safe.
Inheritance: ConnectionDescriptor
Datei anzeigen Open project: azavea/net-dao Class Usage Examples

Public Methods

Method Description
CanUseAliasInOrderClause ( ) : bool

Once we've aliased a function (such as COUNT(*)), can we use that alias in the order by clause or do we need to put the function again?

CaseInsensitiveLikeOperator ( ) : string

The specific operator for doing case insensitive expressions

ColumnAliasPrefix ( ) : string

Some databases want the " AS " keyword, some want the alias in quotes (cough SQLite cough), or square brackets (cough Microsoft cough), or whatever. This provides the database-specific stuff that comes before the alias.

ColumnAliasSuffix ( ) : string

Some databases want the " AS " keyword, some want the alias in quotes (cough SQLite cough), or square brackets (cough Microsoft cough), or whatever. This provides the database-specific stuff that comes after the alias.

CreateDataAccessLayer ( ) : IDaLayer

Returns the appropriate data access layer for this connection. The default implementation returns a normal SQL data access layer, but this may be overridden in particular DB connection descriptors.

CreateNewAdapter ( IDbCommand cmd ) : DbDataAdapter

This method returns a DbDataAdapter that can be used to fill DataSets.

CreateNewConnection ( ) : DbConnection

This method returns a database connection to the database specified by this connection descriptor. This is not meant to be called by client code, only by the utilities in the Azavea.Database assembly.

FullOuterJoinKeyword ( ) : string

Not all databases have the same syntax for full outer joins. Most use "FULL OUTER JOIN" but some do not.

HasCaseInsensitiveLikeOperator ( ) : bool

Not all databases have a case insensitive LIKE operator, such as ILIKE in postgres. Some databases (SQL Server/Access) use LIKE as case insensitive by default.

LowerCaseFunction ( ) : string

UPPER and LOWER are not actually consistent across databases.

MakeBitwiseAndClause ( string columnName ) : SqlClauseWithValue

Returns a 'bitwise and' sql string, something like "columnName & value", except that the syntax is DB-specific. Throws NotImplementedException if not yet supported for a particular type of connection.

MakeCreateIndexCommand ( string indexName, bool isUnique, string tableName, IEnumerable columnNames ) : string

Returns the SQL statement to create an index on a table. There may be database-specific additional keywords required (such as "COMPUTE STATISTICS"). The default implementation returns a simple standard-sql create index statement.

MakeLastAutoGeneratedIdQuery ( string tableName, string idCol ) : string

Gets the last id generated in an ID column for a table. Some databases can do this more efficiently or correctly than the default way ("select max idcol from table").

MakeModulusClause ( string columnName ) : SqlClauseWithValue

Returns a modulus sql string, something like "columnName % value", except that the syntax is DB-specific. Throws NotImplementedException if not yet supported for a particular type of connection.

MakeSequenceValueQuery ( string sequenceName ) : string

Since different databases have different ideas of what a sequence is, this allows the utility class to support sequences across all different DBs.

NeedAsForColumnAliases ( ) : bool

Does the database require the "AS" keyword for aliasing a column? Most do not, but some (MS Access) do.

NeedToAliasColumns ( ) : bool

Does this database require that we alias the columns explicitly if we are aliasing the table name? Most DBs will alias the columns for you (I.E. if you "SELECT ID FROM TABLE1 AS ALIAS1" then the column will be called "ALIAS1.ID", etc). However some require that you alias the columns specifically (cough SQLite, Access cough).

SetParametersOnCommand ( IDbCommand cmd, IEnumerable parameters ) : void

Each driver seems to have its own way of marking parameters ("?", ":param", "@PARAM", etc). So, the database utilities class always uses "?" and relies on the specific descriptor to replace the ? with the appropriate names in the SQL, and also to set the parameters on the command object.

SupportsTruncate ( ) : bool

Nearly every DB in the universe supports truncate, but a few (cough Access cough) do not.

TableAliasPrefix ( ) : string

Some databases want the " AS " keyword, some don't (cough Oracle cough). This provides the database-specific stuff that comes before the alias.

TableAliasSuffix ( ) : string

Some databases want the " AS " keyword, some don't (cough Oracle cough). This provides the database-specific stuff that comes after the alias.

UsePooling ( ) : bool

Depending on the database and connection info, it may not always be appropriate to pool connections. This allows the connection descriptor to decide.

Method Details

CanUseAliasInOrderClause() public method

Once we've aliased a function (such as COUNT(*)), can we use that alias in the order by clause or do we need to put the function again?
public CanUseAliasInOrderClause ( ) : bool
return bool

CaseInsensitiveLikeOperator() public method

The specific operator for doing case insensitive expressions
public CaseInsensitiveLikeOperator ( ) : string
return string

ColumnAliasPrefix() public abstract method

Some databases want the " AS " keyword, some want the alias in quotes (cough SQLite cough), or square brackets (cough Microsoft cough), or whatever. This provides the database-specific stuff that comes before the alias.
public abstract ColumnAliasPrefix ( ) : string
return string

ColumnAliasSuffix() public abstract method

Some databases want the " AS " keyword, some want the alias in quotes (cough SQLite cough), or square brackets (cough Microsoft cough), or whatever. This provides the database-specific stuff that comes after the alias.
public abstract ColumnAliasSuffix ( ) : string
return string

CreateDataAccessLayer() public method

Returns the appropriate data access layer for this connection. The default implementation returns a normal SQL data access layer, but this may be overridden in particular DB connection descriptors.
public CreateDataAccessLayer ( ) : IDaLayer
return IDaLayer

CreateNewAdapter() public abstract method

This method returns a DbDataAdapter that can be used to fill DataSets.
public abstract CreateNewAdapter ( IDbCommand cmd ) : DbDataAdapter
cmd IDbCommand The command that the adapter will be executing.
return System.Data.Common.DbDataAdapter

CreateNewConnection() public abstract method

This method returns a database connection to the database specified by this connection descriptor. This is not meant to be called by client code, only by the utilities in the Azavea.Database assembly.
public abstract CreateNewConnection ( ) : DbConnection
return System.Data.Common.DbConnection

FullOuterJoinKeyword() public method

Not all databases have the same syntax for full outer joins. Most use "FULL OUTER JOIN" but some do not.
public FullOuterJoinKeyword ( ) : string
return string

HasCaseInsensitiveLikeOperator() public method

Not all databases have a case insensitive LIKE operator, such as ILIKE in postgres. Some databases (SQL Server/Access) use LIKE as case insensitive by default.
public HasCaseInsensitiveLikeOperator ( ) : bool
return bool

LowerCaseFunction() public method

UPPER and LOWER are not actually consistent across databases.
public LowerCaseFunction ( ) : string
return string

MakeBitwiseAndClause() public method

Returns a 'bitwise and' sql string, something like "columnName & value", except that the syntax is DB-specific. Throws NotImplementedException if not yet supported for a particular type of connection.
public MakeBitwiseAndClause ( string columnName ) : SqlClauseWithValue
columnName string The column used in the clause.
return SqlClauseWithValue

MakeCreateIndexCommand() public method

Returns the SQL statement to create an index on a table. There may be database-specific additional keywords required (such as "COMPUTE STATISTICS"). The default implementation returns a simple standard-sql create index statement.
public MakeCreateIndexCommand ( string indexName, bool isUnique, string tableName, IEnumerable columnNames ) : string
indexName string Name of the index to create.
isUnique bool Is this a unique index?
tableName string What table to create the index on.
columnNames IEnumerable The columns included in the index.
return string

MakeLastAutoGeneratedIdQuery() public method

Gets the last id generated in an ID column for a table. Some databases can do this more efficiently or correctly than the default way ("select max idcol from table").
public MakeLastAutoGeneratedIdQuery ( string tableName, string idCol ) : string
tableName string The table the ID column belongs to.
idCol string The ID column for which to get the last generated ID value.
return string

MakeModulusClause() public method

Returns a modulus sql string, something like "columnName % value", except that the syntax is DB-specific. Throws NotImplementedException if not yet supported for a particular type of connection.
public MakeModulusClause ( string columnName ) : SqlClauseWithValue
columnName string The column used in the clause.
return SqlClauseWithValue

MakeSequenceValueQuery() public method

Since different databases have different ideas of what a sequence is, this allows the utility class to support sequences across all different DBs.
public MakeSequenceValueQuery ( string sequenceName ) : string
sequenceName string The name of the sequence we're getting an ID from.
return string

NeedAsForColumnAliases() public abstract method

Does the database require the "AS" keyword for aliasing a column? Most do not, but some (MS Access) do.
public abstract NeedAsForColumnAliases ( ) : bool
return bool

NeedToAliasColumns() public abstract method

Does this database require that we alias the columns explicitly if we are aliasing the table name? Most DBs will alias the columns for you (I.E. if you "SELECT ID FROM TABLE1 AS ALIAS1" then the column will be called "ALIAS1.ID", etc). However some require that you alias the columns specifically (cough SQLite, Access cough).
public abstract NeedToAliasColumns ( ) : bool
return bool

SetParametersOnCommand() public abstract method

Each driver seems to have its own way of marking parameters ("?", ":param", "@PARAM", etc). So, the database utilities class always uses "?" and relies on the specific descriptor to replace the ? with the appropriate names in the SQL, and also to set the parameters on the command object.
public abstract SetParametersOnCommand ( IDbCommand cmd, IEnumerable parameters ) : void
cmd IDbCommand Database command (with .Text already populated with sql) that needs /// the parameters set on it.
parameters IEnumerable The parameter values, in the order that the ?'s appear in the /// command's text. This collection should not be null.
return void

SupportsTruncate() public method

Nearly every DB in the universe supports truncate, but a few (cough Access cough) do not.
public SupportsTruncate ( ) : bool
return bool

TableAliasPrefix() public abstract method

Some databases want the " AS " keyword, some don't (cough Oracle cough). This provides the database-specific stuff that comes before the alias.
public abstract TableAliasPrefix ( ) : string
return string

TableAliasSuffix() public abstract method

Some databases want the " AS " keyword, some don't (cough Oracle cough). This provides the database-specific stuff that comes after the alias.
public abstract TableAliasSuffix ( ) : string
return string

UsePooling() public abstract method

Depending on the database and connection info, it may not always be appropriate to pool connections. This allows the connection descriptor to decide.
public abstract UsePooling ( ) : bool
return bool