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.SqlStringAccessor< TResult > Class Template Reference

Represents a call to the database using SQL that will return an enumerable of TResult . More...

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

Public Member Functions

 SqlStringAccessor (Database database, string sqlString, IRowMapper< TResult > rowMapper)
 Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses rowMapper to convert the returned rows to CLR type TResult . More...
 
 SqlStringAccessor (Database database, string sqlString, IResultSetMapper< TResult > resultSetMapper)
 Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses resultSetMapper to convert the returned set to an enumerable of CLR type TResult . More...
 
 SqlStringAccessor (Database database, string sqlString, IParameterMapper parameterMapper, IRowMapper< TResult > rowMapper)
 Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses rowMapper to convert the returned rows to CLR type TResult . The parameterMapper will be used to interpret the parameters passed to the Execute method. More...
 
 SqlStringAccessor (Database database, string sqlString, IParameterMapper parameterMapper, IResultSetMapper< TResult > resultSetMapper)
 Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses resultSetMapper to convert the returned set to an enumerable of CLR type TResult . The parameterMapper will be used to interpret the parameters passed to the Execute method. More...
 
override IEnumerable< TResult > Execute (params object[] parameterValues)
 Executes the SQL query and returns an enumerable of TResult . The enumerable returned by this method uses deferred loading to return the results. More...
 
override IAsyncResult BeginExecute (AsyncCallback callback, object state, params object[] parameterValues)
 Begin executing the SQL query asynchronously. Only supported if the underlying Database object supports asynchronous operations. More...
 
override IEnumerable< TResult > EndExecute (IAsyncResult asyncResult)
 Complete an operation started by DataAccessor<TResult>.BeginExecute. More...
 

Protected Member Functions

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

Represents a call to the database using SQL that will return an enumerable of TResult .

Template Parameters
TResultThe element type that will be used to consume the result set.

Constructor & Destructor Documentation

◆ SqlStringAccessor() [1/4]

Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >.SqlStringAccessor ( Database  database,
string  sqlString,
IRowMapper< TResult >  rowMapper 
)

Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses rowMapper to convert the returned rows to CLR type TResult .

Parameters
databaseThe Database used to execute the SQL.
sqlStringThe SQL that will be executed.
rowMapperThe IRowMapper<TResult> that will be used to convert the returned data to clr type TResult .

◆ SqlStringAccessor() [2/4]

Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >.SqlStringAccessor ( Database  database,
string  sqlString,
IResultSetMapper< TResult >  resultSetMapper 
)

Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses resultSetMapper to convert the returned set to an enumerable of CLR type TResult .

Parameters
databaseThe Database used to execute the SQL.
sqlStringThe SQL that will be executed.
resultSetMapperThe IResultSetMapper<TResult> that will be used to convert the returned set to an enumerable of clr type TResult .

◆ SqlStringAccessor() [3/4]

Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >.SqlStringAccessor ( Database  database,
string  sqlString,
IParameterMapper  parameterMapper,
IRowMapper< TResult >  rowMapper 
)

Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses rowMapper to convert the returned rows to CLR type TResult . The parameterMapper will be used to interpret the parameters passed to the Execute method.

Parameters
databaseThe Database used to execute the SQL.
sqlStringThe SQL that will be executed.
parameterMapperThe IParameterMapper that will be used to interpret the parameters passed to the Execute method.
rowMapperThe IRowMapper<TResult> that will be used to convert the returned data to clr type TResult .
Exceptions
ArgumentExceptionsqlString is null or empty.
ArgumentNullExceptionparameterMapper is null.

◆ SqlStringAccessor() [4/4]

Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >.SqlStringAccessor ( Database  database,
string  sqlString,
IParameterMapper  parameterMapper,
IResultSetMapper< TResult >  resultSetMapper 
)

Creates a new instance of SqlStringAccessor<TResult> that works for a specific database and uses resultSetMapper to convert the returned set to an enumerable of CLR type TResult . The parameterMapper will be used to interpret the parameters passed to the Execute method.

Parameters
databaseThe Database used to execute the SQL.
sqlStringThe SQL that will be executed.
parameterMapperThe IParameterMapper that will be used to interpret the parameters passed to the Execute method.
resultSetMapperThe IResultSetMapper<TResult> that will be used to convert the returned set to an enumerable of clr type TResult .
Exceptions
ArgumentExceptionsqlString is null or empty.
ArgumentNullExceptionparameterMapper is null.

Member Function Documentation

◆ BeginExecute() [1/2]

override IAsyncResult Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >.BeginExecute ( AsyncCallback  callback,
object  state,
params object[]  parameterValues 
)
virtual

Begin executing the SQL query asynchronously. Only supported if the underlying Database object supports asynchronous operations.

Parameters
callbackAsynchronous callback to execute when the result of the query is available. May be null if no callback is desired.
stateExtra arbitrary state information to pass to the callback. May be null.
parameterValuesParameters to pass to the sql query.
Returns
An IAsyncResult object representing the pending request.

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

◆ BeginExecute() [2/2]

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

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)
virtualinherited

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)
protectedinherited

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]

override IEnumerable<TResult> Microsoft.Practices.EnterpriseLibrary.Data.SqlStringAccessor< TResult >.Execute ( params object[]  parameterValues)
virtual

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

Parameters
parameterValuesValues that will be interpret by an IParameterMapper and function as parameters to the Transact SQL query.
Returns
An enumerable of TResult .

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

◆ GuardAsyncAllowed()

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

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: