November Happy Hour will be moved to Thursday December 5th.

Class DbDataStoreProvider

Abstract database implementation of DataStoreProvider Implementors of DataStoreProvider a Data Store Provider using a database should derive from this class

Inheritance
System.Object
DbDataStoreProvider
Namespace: EPiServer.Data.Dynamic.Providers
Assembly: EPiServer.Data.dll
Version: 9.12.2
Syntax
public abstract class DbDataStoreProvider : DataStoreProvider

Constructors

DbDataStoreProvider()

Declaration
protected DbDataStoreProvider()

Fields

ConnectionStringName

Declaration
protected const string ConnectionStringName = "connectionStringName"
Field Value
Type Description
System.String

DeadlockRetriesName

Declaration
protected const string DeadlockRetriesName = "deadlockRetries"
Field Value
Type Description
System.String

DeadlockRetryDelayName

Declaration
protected const string DeadlockRetryDelayName = "deadlockRetryDelay"
Field Value
Type Description
System.String

Properties

Database

The database handler that is being used for this instance

Declaration
public virtual IDatabaseHandler Database { get; }
Property Value
Type Description
IDatabaseHandler

ReferenceTableInformation

Declaration
public override TableInformation ReferenceTableInformation { get; }
Property Value
Type Description
TableInformation
Overrides

Methods

AddResultSetParametersToCollection(IDataParameterCollection, Int32)

Adds resultSetCount number of result set parameters to the parameters collection This is only needed for ADO.NET providers that return the result set as out parameters

Declaration
protected virtual void AddResultSetParametersToCollection(IDataParameterCollection parameters, int resultSetCount)
Parameters
Type Name Description
System.Data.IDataParameterCollection parameters

The parameters collection to add to

System.Int32 resultSetCount

The number of parameters that should be added

ConvertToGuid(Object)

Declaration
protected abstract Guid ConvertToGuid(object value)
Parameters
Type Name Description
System.Object value
Returns
Type Description
System.Guid

CreateParameter(String, DbType, ParameterDirection, Object)

Override this to create a System.Data.IDbDataParameter parameter

Declaration
protected abstract IDbDataParameter CreateParameter(string name, DbType dbType, ParameterDirection direction, object value)
Parameters
Type Name Description
System.String name

The name of the parameter to create

System.Data.DbType dbType

The System.Data.DbType of the parameter

System.Data.ParameterDirection direction

The System.Data.ParameterDirection of the parameter

System.Object value

The value to set into the parameter

Returns
Type Description
System.Data.IDbDataParameter

An instance of a System.Data.IDbDataParameter

CreateParameter(String, DbType, Int32)

Override this to create a System.Data.IDbDataParameter parameter

Declaration
protected virtual IDbDataParameter CreateParameter(string name, DbType dbType, int size)
Parameters
Type Name Description
System.String name

The name of the parameter to create

System.Data.DbType dbType

The System.Data.DbType of the parameter

System.Int32 size

The size of the input

Returns
Type Description
System.Data.IDbDataParameter

An instance of a System.Data.IDbDataParameter

CreateParameter(String, Object)

Override this to create a System.Data.IDbDataParameter parameter

Declaration
public abstract IDbDataParameter CreateParameter(string name, object value)
Parameters
Type Name Description
System.String name

The name of the parameter to create

System.Object value

The value to set into the parameter

Returns
Type Description
System.Data.IDbDataParameter

An instance of a System.Data.IDbDataParameter

Delete(Identity)

Declaration
public override void Delete(Identity id)
Parameters
Type Name Description
Identity id
Overrides

DeleteAll(String)

Declaration
public override void DeleteAll(string storeName)
Parameters
Type Name Description
System.String storeName
Overrides

DeleteStoreDefinition(String, Boolean)

Declaration
public override void DeleteStoreDefinition(string storeName, bool deleteObjects)
Parameters
Type Name Description
System.String storeName
System.Boolean deleteObjects
Overrides

ExecuteList<T>(Query)

Declaration
protected override IList<T> ExecuteList<T>(Query query)
Parameters
Type Name Description
Query query
Returns
Type Description
System.Collections.Generic.IList<T>
Type Parameters
Name Description
T
Overrides

ExecuteLocked(String, Action)

Executes an action with acuiring a lock.

Declaration
public override void ExecuteLocked(string resourceName, Action action)
Parameters
Type Name Description
System.String resourceName

Name of the lock.

System.Action action

The action.

Overrides

ExecuteScalar<T>(Query)

Declaration
protected override T ExecuteScalar<T>(Query query)
Parameters
Type Name Description
Query query
Returns
Type Description
T
Type Parameters
Name Description
T
Overrides

ExecuteTransaction(Action)

This is just a shortcut to

Declaration
public override void ExecuteTransaction(Action action)
Parameters
Type Name Description
System.Action action

The action to run

Overrides

Find<T>(ProviderCallContext, IDictionary<String, Object>, DynamicDataStore)

Declaration
public override IEnumerable<T> Find<T>(ProviderCallContext context, IDictionary<string, object> parameters, DynamicDataStore store)
Parameters
Type Name Description
ProviderCallContext context
System.Collections.Generic.IDictionary<System.String, System.Object> parameters
DynamicDataStore store
Returns
Type Description
System.Collections.Generic.IEnumerable<T>
Type Parameters
Name Description
T
Overrides

GetCreateSaveSPCommandText(StoreDefinition)

Get the SQL for the 'Create Save Procedure' command

Declaration
protected abstract string GetCreateSaveSPCommandText(StoreDefinition storeDefinition)
Parameters
Type Name Description
StoreDefinition storeDefinition

The store definition to create the view for

Returns
Type Description
System.String

A System.String

GetCreateViewCommandText(StoreDefinition)

Get the SQL for the 'Create View' command

Declaration
protected abstract string GetCreateViewCommandText(StoreDefinition storeDefinition)
Parameters
Type Name Description
StoreDefinition storeDefinition

The store definition to create the view for

Returns
Type Description
System.String

A System.String

GetDeleteAllProcedureCommand(String)

Get the 'Delete All Items' command

Declaration
protected abstract DbCommand GetDeleteAllProcedureCommand(string storeName)
Parameters
Type Name Description
System.String storeName

The name of the store to delete items from

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetDeleteExcessReferencesCommand(Int64, String, Int32)

Get the 'Delete Excess References' command

Declaration
protected abstract DbCommand GetDeleteExcessReferencesCommand(long id, string propertyName, int startIndex)
Parameters
Type Name Description
System.Int64 id

The store id of the item to delete excess references for

System.String propertyName

The property name the reference is associated with

System.Int32 startIndex

The index of the item and items with higer indexes that should be deleted

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetDeleteProcedureCommand(Identity)

Get the 'Delete Item Procedure' command

Declaration
protected abstract DbCommand GetDeleteProcedureCommand(Identity id)
Parameters
Type Name Description
Identity id

The Identity for the item to be deleted

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetDropSaveSPCommandText(String)

Get the SQL for the 'Drop Save Procedure' command

Declaration
protected abstract string GetDropSaveSPCommandText(string storeName)
Parameters
Type Name Description
System.String storeName

The name of the store to drop the view for

Returns
Type Description
System.String

A System.String

GetDropViewCommandText(String)

Get the SQL for the 'Drop View' command

Declaration
protected abstract string GetDropViewCommandText(string storeName)
Parameters
Type Name Description
System.String storeName

The name of the store to drop the view for

Returns
Type Description
System.String

A System.String

GetEntityReferenceCountCommand(IEntity)

Creates a command that returns the number of Dynamic Data Store objects that reference a specific IEntity.

Declaration
protected abstract DbCommand GetEntityReferenceCountCommand(IEntity entity)
Parameters
Type Name Description
IEntity entity

The IEntity for which reference should be counted.

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance that should be run by calling ExecuteScalar to return the number of references.

GetLoadCollectionCommand(Identity, String)

Get the 'Load Collection' command

Declaration
protected abstract DbCommand GetLoadCollectionCommand(Identity id, string propertyName)
Parameters
Type Name Description
Identity id

The Identity of the item to load references for

System.String propertyName

The name of the property the collection belongs to

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetLoadCommand(String, IDictionary<String, Object>, IEnumerable<InlinePropertyMap>)

Get the 'Load Item' command

Declaration
protected abstract DbCommand GetLoadCommand(string storeName, IDictionary<string, object> parameters, IEnumerable<InlinePropertyMap> inlineProperties)
Parameters
Type Name Description
System.String storeName

The name of the store the item belongs to

System.Collections.Generic.IDictionary<System.String, System.Object> parameters

Name/Value parameters identifying how the item should be found

System.Collections.Generic.IEnumerable<InlinePropertyMap> inlineProperties

The properties to read from the database

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetLoadReferencesCommand(Identity)

Get the 'Load Reference' command

Declaration
protected abstract DbCommand GetLoadReferencesCommand(Identity id)
Parameters
Type Name Description
Identity id

The Identity of the item to load references for

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetMoveDataCommand(StoreDefinition)

Get a command to move data between columns in the underlying storage table

Declaration
protected abstract DbCommand GetMoveDataCommand(StoreDefinition storeDefinition)
Parameters
Type Name Description
StoreDefinition storeDefinition

The store definition which data is to be moved for

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetSaveInlinePropertiesCommand(ProviderCallContext)

Get the 'Save Inline Properties' command

Declaration
protected abstract DbCommand GetSaveInlinePropertiesCommand(ProviderCallContext context)
Parameters
Type Name Description
ProviderCallContext context

The ProviderCallContext containing information for the save

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetSaveReferencePropertyCommand(PropertyMapType, DbType, Int64, String, Boolean, Int32, Type, Type, String, String, Object)

Get the 'Save Reference Property' command. This used for both single references and collection items

Declaration
protected abstract DbCommand GetSaveReferencePropertyCommand(PropertyMapType propertyType, DbType dataType, long id, string propertyName, bool isKey, int index, Type collectionType, Type elementType, string elementStoreName, string columnName, object value)
Parameters
Type Name Description
PropertyMapType propertyType

The type of property map

System.Data.DbType dataType

The database data type

System.Int64 id

The store id of the parent item

System.String propertyName

The property name the reference is associated with

System.Boolean isKey

A System.Boolean indicating if this reference is a collection key

System.Int32 index

The index of the item in the collection of 0 for a single reference

System.Type collectionType

The System.Type of the collection containing the item being saved or null for a single reference

System.Type elementType

The System.Type of the item being saved

System.String elementStoreName

The name of the store the related item is saved in or null for non reference types

System.String columnName

The name of the column to save the reference /collection value in

System.Object value

The reference / collection value to be saved

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetSaveReferencePropertyCommand(PropertyMapType, Int64, String, Boolean, Int32, Type, Type, String, IList<Tuple<String, Object, DbType>>)

Get the 'Save Reference Property' command. This used for both single references and collection items

Declaration
protected abstract DbCommand GetSaveReferencePropertyCommand(PropertyMapType propertyType, long id, string propertyName, bool isKey, int index, Type collectionType, Type elementType, string elementStoreName, IList<Tuple<string, object, DbType>> columnValues)
Parameters
Type Name Description
PropertyMapType propertyType

The type of property map

System.Int64 id

The store id of the parent item

System.String propertyName

The property name the reference is associated with

System.Boolean isKey

A System.Boolean indicating if this reference is a collection key

System.Int32 index

The index of the item in the collection of 0 for a single reference

System.Type collectionType

The System.Type of the collection containing the item being saved or null for a single reference

System.Type elementType

The System.Type of the item being saved

System.String elementStoreName

The name of the store the related item is saved in or null for non reference types

System.Collections.Generic.IList<System.Tuple<System.String, System.Object, System.Data.DbType>> columnValues

Name, value, and type for columns to get values from

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetStoreInfoDeleteCommand(String)

Get the 'Store Info Delete' command

Declaration
protected abstract DbCommand GetStoreInfoDeleteCommand(string storeName)
Parameters
Type Name Description
System.String storeName

The name of the store to delete

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetStoreInfoLoadCommand(String, Boolean)

Get the 'Store Info Load' command

Declaration
protected abstract DbCommand GetStoreInfoLoadCommand(string storeName, bool loadInactiveProperties)
Parameters
Type Name Description
System.String storeName

The name of the store to load information for

System.Boolean loadInactiveProperties

A System.Boolean indicating whether inactive properties should be loaded

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetStoreInfoSaveCommand(StoreDefinition)

Get the 'Store Info Save' command

Declaration
protected abstract DbCommand GetStoreInfoSaveCommand(StoreDefinition storeDefinition)
Parameters
Type Name Description
StoreDefinition storeDefinition

The StoreDefinition to save

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetStoreNameForItem(Identity, String)

Declaration
public override string GetStoreNameForItem(Identity id, string tableName)
Parameters
Type Name Description
Identity id
System.String tableName
Returns
Type Description
System.String
Overrides

GetStoreNameForItemCommand(Identity, String)

Get the 'Store Name For Item' command

Declaration
protected abstract DbCommand GetStoreNameForItemCommand(Identity id, string tableName)
Parameters
Type Name Description
Identity id

The Identity of the item to get the store name for

System.String tableName

The name of the 'big' table to search

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetStoreNames()

Declaration
public override IEnumerable<string> GetStoreNames()
Returns
Type Description
System.Collections.Generic.IEnumerable<System.String>
Overrides

GetStoreNamesCommandText()

Get the SQL for the 'Get Store Names' command

Declaration
protected abstract string GetStoreNamesCommandText()
Returns
Type Description
System.String

A System.String

GetStoreSaveProcedureName(String)

Get the database specific 'save' stored procedure name

Declaration
protected abstract string GetStoreSaveProcedureName(string storeName)
Parameters
Type Name Description
System.String storeName

The name of the store the item will be saved to

Returns
Type Description
System.String

A System.String

GetUpdateIndexCommand(Int64, String, Boolean, Int32)

Gets the update index command, which updates the index property in a collection or dictionary for a specific property for a specific item. The index should be updated to an index outside of the current list, to continue holding a reference to an existing object.

Declaration
protected abstract DbCommand GetUpdateIndexCommand(long id, string propertyName, bool isKey, int startIndex)
Parameters
Type Name Description
System.Int64 id

The identity of the item, which will have one of it's properties updated.

System.String propertyName

Name of the property for which the index will be updated.

System.Boolean isKey

If set to true, the property will update the key part of a dictionary. If set to false, the property will update the value part on a dictionary or collection.

System.Int32 startIndex

The start index from where the index update should start. All items from the start index will be updated.

Returns
Type Description
System.Data.Common.DbCommand

A database command containing the update SQL for the index of a collection or dictionary.

GetUpdatePropertyNameInReferenceTableCommand(PropertyMap, StoreDefinition)

Get an System.Data.IDbCommand instance, containing update statement for the property name in the reference table

Declaration
protected abstract DbCommand GetUpdatePropertyNameInReferenceTableCommand(PropertyMap propertyMap, StoreDefinition storeDefinition)
Parameters
Type Name Description
PropertyMap propertyMap

Property map containing old property name and new property name

StoreDefinition storeDefinition

The storeDefinition for the store

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

GetUpdateReferencesPropertyNameCommand(String, String, String, String)

Update the property names for the references

Declaration
public abstract DbCommand GetUpdateReferencesPropertyNameCommand(string storeName, string tableName, string oldPropertyName, string newPropertyName)
Parameters
Type Name Description
System.String storeName

Name of the store.

System.String tableName

Name of the CustomBigtable

System.String oldPropertyName

The old Name of the Property

System.String newPropertyName

The new Name of the Property

Returns
Type Description
System.Data.Common.DbCommand

GetValueOverflowCount(String, InlinePropertyMap, InlinePropertyMap, Object, Object)

Declaration
public override int GetValueOverflowCount(string storeName, InlinePropertyMap propertyMap, InlinePropertyMap oldPropertyMap, object minValue, object maxValue)
Parameters
Type Name Description
System.String storeName
InlinePropertyMap propertyMap
InlinePropertyMap oldPropertyMap
System.Object minValue
System.Object maxValue
Returns
Type Description
System.Int32
Overrides

GetValueOverflowCountCommand(String, DbType, String, String, Type, Object, Object)

Get the 'Value Overflow Count' command

Declaration
protected abstract DbCommand GetValueOverflowCountCommand(string storeName, DbType dataType, string dbDeclarationType, string propertyName, Type dbType, object minValue, object maxValue)
Parameters
Type Name Description
System.String storeName

The name of the store to search in

System.Data.DbType dataType

The database type of maxValue

System.String dbDeclarationType

The name of the datatype in the specific SQL dialect

System.String propertyName

The name of the property to check

System.Type dbType

The old type to be remapped

System.Object minValue

The minimum value that would not cause an underflow

System.Object maxValue

The maximum value that would not cause an overflow

Returns
Type Description
System.Data.Common.DbCommand

An System.Data.IDbCommand instance

Initialize(String, NameValueCollection)

Initializes the provider with configuration seetings. Override this method to do any provider specific initialization.

Declaration
public override void Initialize(string name, NameValueCollection config)
Parameters
Type Name Description
System.String name

The friendly name of the provider.

System.Collections.Specialized.NameValueCollection config

A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.

Overrides
Remarks

Remember to call base.Initialize in implementation

Exceptions
Type Condition
System.ArgumentNullException

The name of the provider is null.

System.ArgumentException

The name of the provider has a length of zero.

System.InvalidOperationException

An attempt is made to call System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection) on a provider after the provider has already been initialized.

Load(ProviderCallContext)

Declaration
public override object Load(ProviderCallContext context)
Parameters
Type Name Description
ProviderCallContext context
Returns
Type Description
System.Object
Overrides

LoadCollection(ProviderCallContext, PropertyMap)

Declaration
protected object LoadCollection(ProviderCallContext context, PropertyMap propertyMap)
Parameters
Type Name Description
ProviderCallContext context
PropertyMap propertyMap
Returns
Type Description
System.Object

LoadReferenceMarkers(IList, ProviderCallContext)

Declaration
protected void LoadReferenceMarkers(IList list, ProviderCallContext context)
Parameters
Type Name Description
System.Collections.IList list
ProviderCallContext context

LoadStoreDefinition(String)

Declaration
public override StoreDefinition LoadStoreDefinition(string storeName)
Parameters
Type Name Description
System.String storeName
Returns
Type Description
StoreDefinition
Overrides

LoadSubObject(Identity, Type, String, ProviderCallContext)

Declaration
protected object LoadSubObject(Identity id, Type type, string storeName, ProviderCallContext context)
Parameters
Type Name Description
Identity id
System.Type type
System.String storeName
ProviderCallContext context
Returns
Type Description
System.Object

ProcessValueFromDb(Type, Object)

Declaration
protected virtual object ProcessValueFromDb(Type dataType, object value)
Parameters
Type Name Description
System.Type dataType
System.Object value
Returns
Type Description
System.Object

ProcessValueFromDb(Type, Object, String, ProviderCallContext, Type)

Declaration
protected virtual object ProcessValueFromDb(Type targetType, object value, string name, ProviderCallContext context, Type targetParentType)
Parameters
Type Name Description
System.Type targetType
System.Object value
System.String name
ProviderCallContext context
System.Type targetParentType
Returns
Type Description
System.Object

ProcessValueToDb(DbType, String, Object, ProviderCallContext)

Declaration
protected virtual object ProcessValueToDb(DbType dataType, string name, object value, ProviderCallContext context)
Parameters
Type Name Description
System.Data.DbType dataType
System.String name
System.Object value
ProviderCallContext context
Returns
Type Description
System.Object

Save(ProviderCallContext)

Declaration
public override void Save(ProviderCallContext context)
Parameters
Type Name Description
ProviderCallContext context
Overrides

SaveCollection(Identity, String, IEnumerable, Boolean, Type, ProviderCallContext, PropertyMapType)

Declaration
protected virtual int SaveCollection(Identity fromId, string propertyName, IEnumerable collection, bool isKey, Type runtimeCollectionType, ProviderCallContext context, PropertyMapType mapType)
Parameters
Type Name Description
Identity fromId
System.String propertyName
System.Collections.IEnumerable collection
System.Boolean isKey
System.Type runtimeCollectionType
ProviderCallContext context
PropertyMapType mapType
Returns
Type Description
System.Int32

The number of items that were saved

SaveStoreDefinition(StoreDefinition)

Declaration
public override void SaveStoreDefinition(StoreDefinition storeDefinition)
Parameters
Type Name Description
StoreDefinition storeDefinition
Overrides

SaveSubObject(String, Object, ProviderCallContext, out String)

Declaration
protected virtual Identity SaveSubObject(string propertyName, object value, ProviderCallContext context, out string storeName)
Parameters
Type Name Description
System.String propertyName
System.Object value
ProviderCallContext context
System.String storeName
Returns
Type Description
Identity

UpdateReferencesPropertyName(String, String, String, String)

Declaration
public override void UpdateReferencesPropertyName(string storeName, string tableName, string oldPropertyName, string newPropertyName)
Parameters
Type Name Description
System.String storeName
System.String tableName
System.String oldPropertyName
System.String newPropertyName
Overrides

Extension Methods