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

Base class for SQL-based data access layers that support DDL commands.
Inheritance: SqlDaJoinableLayer, IDaDdlLayer
Datei anzeigen Open project: azavea/net-dao

Public Methods

Method Description
CreateIndex ( string name, ClassMapping mapping, ICollection propertyNames ) : void

Indexes the data for faster queries. Some data sources may not support indexes (such as CSV files), in which case this should throw a NotSupportedException. If the data source supports indexes, but support for creating them is not yet implemented, this should throw a NotImplementedException.

CreateSequence ( string name ) : void

Sequences are things that automatically generate unique, usually incrementing, numbers. Some data sources may not support sequences, in which case this should throw a NotSupportedException. If the data source supports sequences, but support for creating them is not yet implemented, this should throw a NotImplementedException.

CreateStoreHouse ( ) : void

Creates the store house specified in the connection descriptor. If this data source doesn't use a store house, this method should be a no-op. If this data source DOES use store houses, but support for adding them is not implemented yet, this should throw a NotImplementedException. Store house typically corresponds to "database".

CreateStoreRoom ( ClassMapping mapping ) : void

Creates the store room specified in the connection descriptor. If this data source doesn't use a store room, this method should be a no-op. If this data source DOES use store rooms, but support for adding them is not implemented yet, this should throw a NotImplementedException. Store room typically corresponds to "table".

DeleteIndex ( string name, ClassMapping mapping ) : void

Removes an index on the data for slower queries (but usually faster inserts/updates/deletes). Some data sources may not support indexes (such as CSV files), in which case this method should be a no-op. If the data source supports indexes, but support for deleting them is not yet implemented, this should throw a NotImplementedException. If there is no index with the given name, this should be a no-op.

DeleteSequence ( string name ) : void

Removes a sequence. Some data sources may not support sequences, in which case this method should be a no-op. If the data source supports sequences, but support for deleting them is not yet implemented, this should throw a NotImplementedException. If there is no sequence with the given name, this should be a no-op.

DeleteStoreHouse ( ) : void

Deletes the store house specified in the connection descriptor. If this data source doesn't use a store house, this method should be a no-op. If this data source DOES use store houses, but support for dropping them is not implemented yet, this should throw a NotImplementedException. Store house typically corresponds to "database". If there is no store house with the given name, this should be a no-op.

DeleteStoreRoom ( ClassMapping mapping ) : void

Deletes the store room specified in the connection descriptor. If this data source doesn't use a store room, this method should be a no-op. If this data source DOES use store rooms, but support for adding them is not implemented yet, this should throw a NotImplementedException. Store room typically corresponds to "table". If there is no store room with the given name, this should be a no-op.

GenerateClassMappingFromStoreRoom ( string storeRoomName, IComparer columnSorter ) : ClassMapping

Uses some form of introspection to determine what data is stored in this data store, and generates a ClassMapping that can be immediately used with a DictionaryDAO. As much data as practical will be populated on the ClassMapping, at a bare minimum the Table (typically set to the storeRoomName passed in, or the more correct or fully qualified version of that name), the TypeName (set to the storeRoomName, since we have no .NET type), and the "data cols" and "obj attrs" will be the list of attributes / columns in the data source, mapped to themselves.

IndexExists ( string name, ClassMapping mapping ) : bool

Returns whether an index with this name exists or not. NOTE: This does NOT verify what properties the index is on, merely whether an index with this name is already present.

SequenceExists ( string name ) : bool

Returns whether a sequence with this name exists or not.

StoreHouseMissing ( ) : bool

Returns true if you need to call "CreateStoreHouse" before storing any data. This method is "Missing" not "Exists" because implementations that do not use a store house (I.E. single-file-based data access layers) can return "false" from this method without breaking either a user's app or the spirit of the method. Store house typically corresponds to "database".

StoreRoomMissing ( ClassMapping mapping ) : bool

Returns true if you need to call "CreateStoreRoom" before storing any data. This method is "Missing" not "Exists" because implementations that do not use a store room can return "false" from this method without breaking either a user's app or the spirit of the method. Store room typically corresponds to "table".

Protected Methods

Method Description
AddColDefinition ( StringBuilder sb, string col, ClassMapping mapping, string separator, ICollection extraStatements ) : bool

Add the definition for the given column to the create table statement.

GetAsciiStringType ( ) : string

Returns the SQL type used to store an ascii string in the DB.

GetAutoType ( Type baseType ) : string

Returns the DDL for the type of an automatically incrementing column. Some databases only store autonums in one col type so baseType may be ignored.

GetBooleanType ( ) : string

Returns the SQL type used to store a boolean in the DB.

GetByteArrayType ( ) : string

Returns the SQL type used to store a byte array in the DB.

GetByteType ( ) : string

Returns the SQL type used to store a byte in the DB.

GetCharType ( ) : string

Returns the SQL type used to store a char in the DB.

GetDateTimeType ( ) : string

Returns the SQL type used to store a DateTime in the DB.

GetDoubleType ( ) : string

Returns the SQL type used to store a double in the DB.

GetFloatType ( ) : string

Returns the SQL type used to store a float in the DB.

GetGeneratorType ( string col, ClassMapping mapping ) : GeneratorType

For a column, returns the type of generator used for it.

GetIntType ( ) : string

Returns the SQL type used to store an integer in the DB.

GetLongType ( ) : string

Returns the SQL type used to store a long in the DB.

GetShortType ( ) : string

Returns the SQL type used to store a short in the DB.

GetStringType ( ) : string

Returns the SQL type used to store a "normal" (unicode) string in the DB.

SqlDaDdlLayer ( AbstractSqlConnectionDescriptor connDesc, bool supportsNumRecords ) : System

Instantiates the data access layer with the connection descriptor for the DB.

Method Details

AddColDefinition() protected method

Add the definition for the given column to the create table statement.
protected AddColDefinition ( StringBuilder sb, string col, ClassMapping mapping, string separator, ICollection extraStatements ) : bool
sb StringBuilder Current create table statement to append to.
col string Name of the column to add a definition for.
mapping ClassMapping Classmap for the class we're generating columns for.
separator string Separator to use before appending to sb.
extraStatements ICollection If adding this column requires any additional /// SQL statements to be run afterwards, put them here.
return bool

CreateIndex() public method

Indexes the data for faster queries. Some data sources may not support indexes (such as CSV files), in which case this should throw a NotSupportedException. If the data source supports indexes, but support for creating them is not yet implemented, this should throw a NotImplementedException.
public CreateIndex ( string name, ClassMapping mapping, ICollection propertyNames ) : void
name string Name of the index. Some data sources require names for indexes, /// and even if not this is required so the index can be deleted if desired.
mapping ClassMapping ClassMapping for the data that is being indexed.
propertyNames ICollection Names of the data properties to include in the index (in order).
return void

CreateSequence() public method

Sequences are things that automatically generate unique, usually incrementing, numbers. Some data sources may not support sequences, in which case this should throw a NotSupportedException. If the data source supports sequences, but support for creating them is not yet implemented, this should throw a NotImplementedException.
public CreateSequence ( string name ) : void
name string Name of the new sequence to create.
return void

CreateStoreHouse() public method

Creates the store house specified in the connection descriptor. If this data source doesn't use a store house, this method should be a no-op. If this data source DOES use store houses, but support for adding them is not implemented yet, this should throw a NotImplementedException. Store house typically corresponds to "database".
public CreateStoreHouse ( ) : void
return void

CreateStoreRoom() public method

Creates the store room specified in the connection descriptor. If this data source doesn't use a store room, this method should be a no-op. If this data source DOES use store rooms, but support for adding them is not implemented yet, this should throw a NotImplementedException. Store room typically corresponds to "table".
public CreateStoreRoom ( ClassMapping mapping ) : void
mapping ClassMapping ClassMapping for the data that will be stored in this room.
return void

DeleteIndex() public method

Removes an index on the data for slower queries (but usually faster inserts/updates/deletes). Some data sources may not support indexes (such as CSV files), in which case this method should be a no-op. If the data source supports indexes, but support for deleting them is not yet implemented, this should throw a NotImplementedException. If there is no index with the given name, this should be a no-op.
public DeleteIndex ( string name, ClassMapping mapping ) : void
name string Name of the index to delete.
mapping ClassMapping ClassMapping for the data that was being indexed.
return void

DeleteSequence() public method

Removes a sequence. Some data sources may not support sequences, in which case this method should be a no-op. If the data source supports sequences, but support for deleting them is not yet implemented, this should throw a NotImplementedException. If there is no sequence with the given name, this should be a no-op.
public DeleteSequence ( string name ) : void
name string Name of the sequence to delete.
return void

DeleteStoreHouse() public method

Deletes the store house specified in the connection descriptor. If this data source doesn't use a store house, this method should be a no-op. If this data source DOES use store houses, but support for dropping them is not implemented yet, this should throw a NotImplementedException. Store house typically corresponds to "database". If there is no store house with the given name, this should be a no-op.
public DeleteStoreHouse ( ) : void
return void

DeleteStoreRoom() public method

Deletes the store room specified in the connection descriptor. If this data source doesn't use a store room, this method should be a no-op. If this data source DOES use store rooms, but support for adding them is not implemented yet, this should throw a NotImplementedException. Store room typically corresponds to "table". If there is no store room with the given name, this should be a no-op.
public DeleteStoreRoom ( ClassMapping mapping ) : void
mapping ClassMapping ClassMapping for the data that was stored in this room.
return void

GenerateClassMappingFromStoreRoom() public method

Uses some form of introspection to determine what data is stored in this data store, and generates a ClassMapping that can be immediately used with a DictionaryDAO. As much data as practical will be populated on the ClassMapping, at a bare minimum the Table (typically set to the storeRoomName passed in, or the more correct or fully qualified version of that name), the TypeName (set to the storeRoomName, since we have no .NET type), and the "data cols" and "obj attrs" will be the list of attributes / columns in the data source, mapped to themselves.
public GenerateClassMappingFromStoreRoom ( string storeRoomName, IComparer columnSorter ) : ClassMapping
storeRoomName string The name of the storeroom (I.E. table). May be null /// if this data source does not use store rooms.
columnSorter IComparer If you wish the columns / attributes to be in a particular /// order, supply this optional parameter. May be null.
return ClassMapping

GetAsciiStringType() protected method

Returns the SQL type used to store an ascii string in the DB.
protected GetAsciiStringType ( ) : string
return string

GetAutoType() protected abstract method

Returns the DDL for the type of an automatically incrementing column. Some databases only store autonums in one col type so baseType may be ignored.
protected abstract GetAutoType ( Type baseType ) : string
baseType System.Type The data type of the column (nominally).
return string

GetBooleanType() protected method

Returns the SQL type used to store a boolean in the DB.
protected GetBooleanType ( ) : string
return string

GetByteArrayType() protected abstract method

Returns the SQL type used to store a byte array in the DB.
protected abstract GetByteArrayType ( ) : string
return string

GetByteType() protected method

Returns the SQL type used to store a byte in the DB.
protected GetByteType ( ) : string
return string

GetCharType() protected method

Returns the SQL type used to store a char in the DB.
protected GetCharType ( ) : string
return string

GetDateTimeType() protected method

Returns the SQL type used to store a DateTime in the DB.
protected GetDateTimeType ( ) : string
return string

GetDoubleType() protected method

Returns the SQL type used to store a double in the DB.
protected GetDoubleType ( ) : string
return string

GetFloatType() protected method

Returns the SQL type used to store a float in the DB.
protected GetFloatType ( ) : string
return string

GetGeneratorType() protected method

For a column, returns the type of generator used for it.
protected GetGeneratorType ( string col, ClassMapping mapping ) : GeneratorType
col string Column to look up.
mapping ClassMapping Mapping for the class we're creating a table for.
return GeneratorType

GetIntType() protected method

Returns the SQL type used to store an integer in the DB.
protected GetIntType ( ) : string
return string

GetLongType() protected abstract method

Returns the SQL type used to store a long in the DB.
protected abstract GetLongType ( ) : string
return string

GetShortType() protected method

Returns the SQL type used to store a short in the DB.
protected GetShortType ( ) : string
return string

GetStringType() protected method

Returns the SQL type used to store a "normal" (unicode) string in the DB.
protected GetStringType ( ) : string
return string

IndexExists() public method

Returns whether an index with this name exists or not. NOTE: This does NOT verify what properties the index is on, merely whether an index with this name is already present.
public IndexExists ( string name, ClassMapping mapping ) : bool
name string Name of the index to check for.
mapping ClassMapping ClassMapping for the data that may be indexed.
return bool

SequenceExists() public method

Returns whether a sequence with this name exists or not.
public SequenceExists ( string name ) : bool
name string Name of the sequence to check for.
return bool

SqlDaDdlLayer() protected method

Instantiates the data access layer with the connection descriptor for the DB.
protected SqlDaDdlLayer ( AbstractSqlConnectionDescriptor connDesc, bool supportsNumRecords ) : System
connDesc AbstractSqlConnectionDescriptor The connection descriptor that is being used by this FastDaoLayer.
supportsNumRecords bool If true, methods that return numbers of records affected will be /// returning accurate numbers. If false, they will probably return /// FastDAO.UNKNOWN_NUM_ROWS.
return System

StoreHouseMissing() public method

Returns true if you need to call "CreateStoreHouse" before storing any data. This method is "Missing" not "Exists" because implementations that do not use a store house (I.E. single-file-based data access layers) can return "false" from this method without breaking either a user's app or the spirit of the method. Store house typically corresponds to "database".
public StoreHouseMissing ( ) : bool
return bool

StoreRoomMissing() public method

Returns true if you need to call "CreateStoreRoom" before storing any data. This method is "Missing" not "Exists" because implementations that do not use a store room can return "false" from this method without breaking either a user's app or the spirit of the method. Store room typically corresponds to "table".
public StoreRoomMissing ( ClassMapping mapping ) : bool
mapping ClassMapping
return bool