Enterprise Library Data Access Application Block  7.0-rc1
The Data Access Application Block abstracts the actual database you are using, and exposes a collection of methods that make it easy to access that database and to perform common tasks.
Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult > Class Template Referenceabstract

Base class for Data Accessors that execute a DbCommand. More...

Inheritance diagram for Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult >:
Microsoft.Practices.EnterpriseLibrary.Data.DataAccessor< TResult > Microsoft.Practices.EnterpriseLibrary.Data.SprocAccessor< TResult > Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >

Public Member Functions

override IEnumerable< TResult > EndExecute (IAsyncResult asyncResult)
 Complete an operation started by DataAccessor<TResult>.BeginExecute. More...
 
abstract IEnumerable< TResult > Execute (params object[] parameterValues)
 Execute the database operation synchronously, returning the IEnumerable<TResult> sequence containing the resulting objects. More...
 
abstract IAsyncResult BeginExecute (AsyncCallback callback, object state, params object[] parameterValues)
 Begin executing the database object asynchronously, returning a IAsyncResult object that can be used to retrieve the result set after the operation completes. More...
 

Protected Member Functions

 CommandAccessor (Database database, IRowMapper< TResult > rowMapper)
 Initialized the CommandAccessor<TResult> with a database instance and a Row Mapper. More...
 
 CommandAccessor (Database database, IResultSetMapper< TResult > resultSetMapper)
 Initialized the CommandAccessor<TResult> with a database instance and a Row Mapper. More...
 
IEnumerable< TResult > Execute (DbCommand command)
 Executes the command and returns an enumerable of TResult . The enumerable returned by this method uses deferred loading to return the results. More...
 
IAsyncResult BeginExecute (DbCommand command, IParameterMapper parameterMapper, AsyncCallback callback, object state, object[] parameterValues)
 Helper method to kick off execution of an asynchronous database operation. This method handles the boilerplate of setting up the parameters and invoking the operation on the database with the right options. More...
 
void GuardAsyncAllowed ()
 Checks if the current Database object supports asynchronous operations, and throws InvalidOperationException if not. More...
 

Properties

Database Database [get]
 The database object this accessor is wrapped around. More...
 

Detailed Description

Base class for Data Accessors that execute a DbCommand.

Template Parameters
TResultThe element type this accessor will return.

Constructor & Destructor Documentation

◆ CommandAccessor() [1/2]

Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult >.CommandAccessor ( Database  database,
IRowMapper< TResult >  rowMapper 
)
protected

Initialized the CommandAccessor<TResult> with a database instance and a Row Mapper.

Parameters
databaseThe Database used to execute the DbCommand.
rowMapperThe IRowMapper<TResult> that will be used to convert the returned data to clr type TResult .
Exceptions
ArgumentNullExceptionrowMapper is null.

◆ CommandAccessor() [2/2]

Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult >.CommandAccessor ( Database  database,
IResultSetMapper< TResult >  resultSetMapper 
)
protected

Initialized the CommandAccessor<TResult> with a database instance and a Row Mapper.

Parameters
databaseThe Database used to execute the DbCommand.
resultSetMapperThe IResultSetMapper<TResult> that will be used to convert the returned set to an enumerable of clr type TResult .
Exceptions
ArgumentNullExceptiondatabase or resultSetMapper are null.

Member Function Documentation

◆ BeginExecute() [1/2]

abstract IAsyncResult Microsoft.Practices.EnterpriseLibrary.Data.DataAccessor< TResult >.BeginExecute ( AsyncCallback  callback,
object  state,
params object[]  parameterValues 
)
pure virtualinherited

Begin executing the database object asynchronously, returning a IAsyncResult object that can be used to retrieve the result set after the operation completes.

Parameters
callbackCallback to execute when the operation's results are available. May be null if you don't wish to use a callback.
stateExtra information that will be passed to the callback. May be null.
parameterValuesParameters to pass to the database.

This operation will throw if the underlying Database object does not support asynchronous operation.

Exceptions
InvalidOperationExceptionThe underlying database does not support asynchronous operation.
Returns
The IAsyncResult representing this operation.

Implemented in Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >, and Microsoft.Practices.EnterpriseLibrary.Data.SprocAccessor< TResult >.

◆ BeginExecute() [2/2]

IAsyncResult Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult >.BeginExecute ( DbCommand  command,
IParameterMapper  parameterMapper,
AsyncCallback  callback,
object  state,
object[]  parameterValues 
)
protected

Helper method to kick off execution of an asynchronous database operation. This method handles the boilerplate of setting up the parameters and invoking the operation on the database with the right options.

Parameters
commandThe DbCommand to execute.
parameterMapperThe IParameterMapper to use to set the parameter values.
callbackCallback to execute when the operation's result is available.
stateState to pass to the callback.
parameterValuesInput parameter values.
Returns
An IAsyncResult object representing the outstanding async request.

◆ EndExecute()

override IEnumerable<TResult> Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult >.EndExecute ( IAsyncResult  asyncResult)
virtual

Complete an operation started by DataAccessor<TResult>.BeginExecute.

Returns
The result sequence.

Implements Microsoft.Practices.EnterpriseLibrary.Data.DataAccessor< TResult >.

◆ Execute() [1/2]

IEnumerable<TResult> Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult >.Execute ( DbCommand  command)
protected

Executes the command and returns an enumerable of TResult . The enumerable returned by this method uses deferred loading to return the results.

Parameters
commandThe command that will be executed.
Returns
An enumerable of TResult .

◆ Execute() [2/2]

abstract IEnumerable<TResult> Microsoft.Practices.EnterpriseLibrary.Data.DataAccessor< TResult >.Execute ( params object[]  parameterValues)
pure virtualinherited

Execute the database operation synchronously, returning the IEnumerable<TResult> sequence containing the resulting objects.

Parameters
parameterValuesParameters to pass to the database.
Returns
The sequence of result objects.

Implemented in Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >, and Microsoft.Practices.EnterpriseLibrary.Data.SprocAccessor< TResult >.

◆ GuardAsyncAllowed()

void Microsoft.Practices.EnterpriseLibrary.Data.CommandAccessor< TResult >.GuardAsyncAllowed ( )
protected

Checks if the current Database object supports asynchronous operations, and throws InvalidOperationException if not.

Exceptions
InvalidOperationExceptionThe database does not support asynchronous operations.

Property Documentation

◆ Database

The database object this accessor is wrapped around.


The documentation for this class was generated from the following file: