Open.Database.Extensions
DbConnectionFactory
DbConnection factory implementation that accepts a factory function.
Constructor(factory)
Constructs a DbConnectionFactory.
| Name | Description |
|---|---|
| factory | System.Func{System.Data.Common.DbConnection} |
DbConnectionFactory`1
Generic connection factory implementation that accepts a factory function.
Type Parameters
- TConnection -
Constructor(factory)
Constructs a DbConnectionFactory.
| Name | Description |
|---|---|
| factory | System.Func{`0} |
Create
Creates a connection of from the underlying factory function.
ExpressiveCommandBase`4
Base class for developing expressive commands.
Type Parameters
- TConnection - The type of the connection to be used.
- TCommand - The type of the commands generated by the connection.
- TDbType - The DB type enum to use for parameters.
- TThis - The type of this class in order to facilitate proper expressive notation.
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{`0} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param[] The list of params |
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{`0} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | System.Collections.Generic.List{Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param} The list of params |
AddParam(name, value, type)
Adds a parameter to the params list.
| Name | Description |
|---|---|
| name | System.String The name of the parameter. |
| value | System.Object The value of the parameter. |
| type | `2 The database type of the parameter. |
Returns
This instance for use in method chaining.
AddParam(name, value)
Adds a parameter to the params list.
| Name | Description |
|---|---|
| name | System.String The name of the parameter. |
| value | System.Object The value of the parameter. |
Returns
This instance for use in method chaining.
AddParam(name)
Adds a parameter to the params list.
| Name | Description |
|---|---|
| name | System.String The name of the parameter. |
Returns
This instance for use in method chaining.
AddParam``1(name, value, type)
Adds a parameter to the params list.
| Name | Description |
|---|---|
| name | System.String The name of the parameter. |
| value | System.Nullable{``0} The value of the parameter. |
| type | `2 The database type of the parameter. |
Returns
This instance for use in method chaining.
AddParam``1(name, value)
Adds a parameter to the params list.
| Name | Description |
|---|---|
| name | System.String The name of the parameter. |
| value | System.Nullable{``0} The value of the parameter. |
Returns
This instance for use in method chaining.
AddParamIf(condition, name, value, type)
Conditionally adds a parameter to the params list.
| Name | Description |
|---|---|
| condition | System.Boolean The condition to add the param by. Only adds if true. |
| name | System.String The name of the parameter. |
| value | System.Object The value of the parameter. |
| type | `2 The database type of the parameter. |
Returns
This instance for use in method chaining.
AddParamIf(condition, name, value)
Conditionally adds a parameter to the params list.
| Name | Description |
|---|---|
| condition | System.Boolean The condition to add the param by. Only adds if true. |
| name | System.String The name of the parameter. |
| value | System.Object The value of the parameter. |
Returns
This instance for use in method chaining.
AddParamIf(condition, name)
Conditionally adds a parameter to the params list.
| Name | Description |
|---|---|
| condition | System.Boolean The condition to add the param by. Only adds if true. |
| name | System.String The name of the parameter. |
Returns
This instance for use in method chaining.
AddParamIf``1(condition, name, value, type)
Conditionally adds a parameter to the params list.
| Name | Description |
|---|---|
| condition | System.Boolean The condition to add the param by. Only adds if true. |
| name | System.String The name of the parameter. |
| value | System.Nullable{``0} The value of the parameter. |
| type | `2 The database type of the parameter. |
Returns
This instance for use in method chaining.
AddParamIf``1(condition, name, value)
Conditionally adds a parameter to the params list.
| Name | Description |
|---|---|
| condition | System.Boolean The condition to add the param by. Only adds if true. |
| name | System.String The name of the parameter. |
| value | System.Nullable{``0} The value of the parameter. |
Returns
This instance for use in method chaining.
AddParams(command)
Handles adding the list of parameters to a new command.
| Name | Description |
|---|---|
| command | `1 |
AsSourceBlock``1(fieldMappingOverrides, synchronousExecution)
Provides a transform block as the source of records.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
| synchronousExecution | System.Boolean By default the command is deferred. If set to true, the command runs synchronusly and all data is acquired before the method returns. If set to false (default) the data is recieved asynchronously (data will be subsequently posted) and the source block (transform) can be completed early. |
Returns
A transform block that is recieving the results.
AsSourceBlock``1(fieldMappingOverrides, synchronousExecution)
Provides a transform block as the source of records.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
| synchronousExecution | System.Boolean By default the command is deferred. If set to true, the command runs synchronusly and all data is acquired before the method returns. If set to false (default) the data is recieved asynchronously (data will be subsequently posted) and the source block (transform) can be completed early. |
Returns
A transform block that is recieving the results.
AsSourceBlock``1(transform, synchronousExecution)
Returns a buffer block that will contain the results.
Type Parameters
- T - The expected type.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function. |
| synchronousExecution | System.Boolean By default the command is deferred. If set to true, the command runs synchronusly and all data is acquired before the method returns. If set to false (default) the data is recieved asynchronously (deferred: data will be subsequently posted) and the source block (transform) can be completed early. |
Returns
The buffer block that will contain the results.
AsSourceBlock``1(fieldMappingOverrides)
Provides a transform block as the source of records.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A transform block that is recieving the results.
Command
The command text or procedure name to use.
ConnectionFactory
THe connection factory to use to generate connections and commands.
Execute(handler)
Executes a reader on a command with a handler function.
| Name | Description |
|---|---|
| handler | System.Action{`1} The handler function for each IDataRecord. |
Execute``1(transform)
Executes a reader on a command with a transform function.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{`1,``0} The transform function for each IDataRecord. |
Returns
The result of the transform.
ExecuteNonQuery
Calls ExecuteNonQuery on the underlying command.
Returns
The integer response from the method. (Records updated.)
ExecuteReader(handler, behavior)
Executes a reader on a command with a handler function.
| Name | Description |
|---|---|
| handler | System.Action{System.Data.IDataReader} The handler function for the data reader. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
ExecuteReader``1(transform, behavior)
Executes a reader on a command with a transform function.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataReader,``0} The transform function for each IDataRecord. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
Returns
The result of the transform.
ExecuteReturn
Calls ExecuteNonQuery on the underlying command but sets up a return parameter and returns that value.
Returns
The value from the return parameter.
ExecuteReturn``1
Calls ExecuteNonQuery on the underlying command but sets up a return parameter and returns that value.
Returns
The value from the return parameter.
ExecuteScalar
Calls ExecuteScalar on the underlying command.
Returns
The varlue returned from the method.
ExecuteScalar``1
Calls ExecuteScalar on the underlying command.
Type Parameters
- T - The type expected.
Returns
The varlue returned from the method.
ExecuteScalar``1(System.Func{System.Object,``0})
Calls ExecuteScalar on the underlying command.
Type Parameters
- T - The type expected.
Returns
The varlue returned from the method.
First``1(transform)
Iterates an IDataReader and returns the first result through a transform funciton. Throws if none.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
FirstOrDefault``1(transform)
Iterates an IDataReader and returns the first result through a transform funciton. Returns default(T) if none.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
FirstOrdinalResults
Reads the first column from every record and returns the results as a list.. DBNull values are converted to null.
Returns
The list of transformed records.
FirstOrdinalResults``1
Reads the first column from every record.. DBNull values are converted to null.
Returns
The enumerable of casted values.
IterateReader(handler)
Iterates a reader on a command with a handler function.
| Name | Description |
|---|---|
| handler | System.Action{System.Data.IDataRecord} The handler function for each IDataRecord. |
IterateReader``2(transform, selector)
Executes a reader on a command with a transform function.
Type Parameters
- TEntity - The return type of the transform function applied to each record.
- TResult - The type returned by the selector.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function for each IDataRecord. |
| selector | System.Func{System.Collections.Generic.IEnumerable{``0},``1} Provides an IEnumerable |
Returns
The result of the transform.
IterateReaderInternal``1(transform)
Internal reader for simplifying iteration. If exposed publicly could potentially hold connections open because an iteration may have not completed.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function for each IDataRecord. |
Returns
The results of each transformation.
IterateReaderWhile(handler)
Iterates a reader on a command while the handler function returns true.
| Name | Description |
|---|---|
| handler | System.Func{System.Data.IDataRecord,System.Boolean} The handler function for each IDataRecord. |
LoadTable
Imports all data using an IDataReader into a DataTable.
Returns
The resultant DataTabel.
LoadTables
Loads all data from a command through an IDataReader into a DataTables. Calls .NextResult() to check for more results.
Returns
The resultant list of DataTables.
Param
A struct that represents the param to be created when the command is exectued.
Equals(obj)
Determines whether the specified param is equal to the current one.
| Name | Description |
|---|---|
| obj | System.Object Param to compare against. |
Returns
True if properties are equal.
Name
The name of the param.
op_Equality(Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param,Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param)
Equality operator.
op_Inequality(Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param,Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param)
Inequality operator.
Type
The DbType of the param.
Value
The value of the param.
Open.Database.Extensions.ExpressiveCommandBase`4.Params
The list of params to apply to the command before execution.
Open.Database.Extensions.ExpressiveCommandBase`4.Results``1(fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Open.Database.Extensions.ExpressiveCommandBase`4.Results``1(fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Open.Database.Extensions.ExpressiveCommandBase`4.Results``1(fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Open.Database.Extensions.ExpressiveCommandBase`4.Retrieve
Iterates all records within the first result set using an IDataReader and returns the results. DBNull values are left unchanged (retained).
Returns
The QueryResult that contains all the results and the column mappings.
Open.Database.Extensions.ExpressiveCommandBase`4.Retrieve(ordinals)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| ordinals | System.Collections.Generic.IEnumerable{System.Int32} The ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Open.Database.Extensions.ExpressiveCommandBase`4.Retrieve(columnNames)
Iterates all records within the first result set using an IDataReader and returns the desired results as a list of Dictionaries containing only the specified column values. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| columnNames | System.Collections.Generic.IEnumerable{System.String} The column names to select. |
Returns
The QueryResult that contains all the results and the column mappings.
Open.Database.Extensions.ExpressiveCommandBase`4.Retrieve(n, others)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| n | System.Int32 The first ordinal to include in the request to the reader for each record. |
| others | System.Int32[] The remaining ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Open.Database.Extensions.ExpressiveCommandBase`4.Retrieve(c, others)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| c | System.String The first column name to include in the request to the reader for each record. |
| others | System.String[] The remaining column names to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Open.Database.Extensions.ExpressiveCommandBase`4.SetTimeout(seconds)
Sets the timeout value.
| Name | Description |
|---|---|
| seconds | System.UInt16 The number of seconds to wait before the connection times out. |
Returns
This instance for use in method chaining.
Open.Database.Extensions.ExpressiveCommandBase`4.Single``1(transform)
Iterates a IDataReader and returns the first result through a transform funciton. Throws if none or more than one entry.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
Open.Database.Extensions.ExpressiveCommandBase`4.SingleOrDefault``1(transform)
Iterates an IDataReader and returns the first result through a transform funciton. Returns default(T) if none. Throws if more than one entry.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
Open.Database.Extensions.ExpressiveCommandBase`4.Skip``1(count, transform)
Iterates an IDataReader and skips the first number of results defined by the count.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| count | System.Int32 The number of records to skip. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The results from the transform after the skip count.
Open.Database.Extensions.ExpressiveCommandBase`4.SkipThenTake``1(skip, take, transform)
Iterates an IDataReader and skips by the skip parameter returns the maximum remaining defined by the take parameter.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| skip | System.Int32 The number of entries to skip before starting to take results. |
| take | System.Int32 The maximum number of records to return. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The results from the skip, transform and take operation.
Open.Database.Extensions.ExpressiveCommandBase`4.Take``1(count, transform)
Iterates an IDataReader and returns the first number of results defined by the count.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| count | System.Int32 The maximum number of records to return. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The results from the transform limited by the take count.
Open.Database.Extensions.ExpressiveCommandBase`4.Timeout
The command timeout value.
Open.Database.Extensions.ExpressiveCommandBase`4.ToArray``1(transform)
Converts all IDataRecords into an array using a transform function.
Type Parameters
- T - The expected return type.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function. |
Returns
The array of transformed records.
Open.Database.Extensions.ExpressiveCommandBase`4.ToList``1(transform)
Converts all IDataRecords into a list using a transform function.
Type Parameters
- T - The expected return type.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function. |
Returns
The list of transformed records.
Open.Database.Extensions.ExpressiveCommandBase`4.ToTargetBlock``1(transform, target)
Posts all records to a target block using the transform function.
Type Parameters
- T - The expected type.
| Name | Description |
|---|---|
| transform | System.Threading.Tasks.Dataflow.ITargetBlock{``0} The transform function. |
| target | System.Func{System.Data.IDataRecord,``0} The target block to receive the results (to be posted to). |
Open.Database.Extensions.ExpressiveCommandBase`4.Type
The command type.
ExpressiveDbCommand
A specialized for SqlClient abstraction for executing commands on a database using best practices and simplified expressive syntax.
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{System.Data.Common.DbConnection} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | Open.Database.Extensions.ExpressiveCommandBase{System.Data.Common.DbConnection,System.Data.Common.DbCommand,System.Data.DbType,Open.Database.Extensions.ExpressiveDbCommand}.Param[] The list of params |
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{System.Data.Common.DbConnection} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | System.Collections.Generic.List{Open.Database.Extensions.ExpressiveCommandBase{System.Data.Common.DbConnection,System.Data.Common.DbCommand,System.Data.DbType,Open.Database.Extensions.ExpressiveDbCommand}.Param} The list of params |
AddParams(command)
Handles adding the list of parameters to a new command.
| Name | Description |
|---|---|
| command | System.Data.Common.DbCommand |
ExpressiveDbCommandBase`4
An abstraction for executing commands on a database using best practices and simplified expressive syntax.
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{`0} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param[] The list of params |
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{`0} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | System.Collections.Generic.List{Open.Database.Extensions.ExpressiveCommandBase{`0,`1,`2,`3}.Param} The list of params |
AsSourceBlockAsync``1(fieldMappingOverrides)
Returns a source block as the source of records.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A transform block that is recieving the results.
AsSourceBlockAsync``1(fieldMappingOverrides)
Returns a source block as the source of records.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A transform block that is recieving the results.
AsSourceBlockAsync``1(transform)
Provides a BufferBlock as the source of records.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A buffer block that is recieving the results.
AsSourceBlockAsync``1(fieldMappingOverrides)
Returns a source block as the source of records.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A transform block that is recieving the results.
ExecuteAsync(handler)
Asynchronously executes a reader on a command with a handler function.
| Name | Description |
|---|---|
| handler | System.Func{`1,System.Threading.Tasks.Task} The handler function for each IDataRecord. |
ExecuteAsync``1(transform)
Asynchronously executes a reader on a command with a transform function.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{`1 The transform function for each IDataRecord. |
Returns
The result of the transform.
ExecuteNonQueryAsync
Calls ExecuteNonQueryAsync on the underlying command.
Returns
The integer responise from the method.
ExecuteReaderAsync(handler, behavior)
Asynchronously executes a reader on a command with a handler function.
| Name | Description |
|---|---|
| handler | System.Func{System.Data.Common.DbDataReader,System.Threading.Tasks.Task} The handler function for the data reader. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
ExecuteReaderAsync``1(transform, behavior)
Asynchronously executes a reader on a command with a transform function.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.Common.DbDataReader The transform function for each IDataRecord. |
| behavior | System.Threading.Tasks.Task{``0}} The command behavior for once the command the reader is complete. |
Returns
The result of the transform.
ExecuteReturnAsync
Calls ExecuteNonQueryAsync on the underlying command but sets up a return parameter and returns that value.
Returns
The value from the return parameter.
ExecuteReturnAsync``1
Calls ExecuteNonQueryAsync on the underlying command but sets up a return parameter and returns that value.
Returns
The value from the return parameter.
ExecuteScalarAsync
Calls ExecuteScalarAsync on the underlying command.
Returns
The value returned from the method.
ExecuteScalarAsync``1
Asynchronously executes scalar on the underlying command and casts to the expected type.
Type Parameters
- T - The type expected.
Returns
The value returned from the method.
ExecuteScalarAsync``1(System.Func{System.Object,``0})
Asynchronously executes scalar on the underlying command.
Type Parameters
- T - The type expected.
Returns
The value returned from the method.
ExecuteScalarAsync``1(System.Func{System.Object,System.Threading.Tasks.Task{``0}})
Asynchronously executes scalar on the underlying command.
Type Parameters
- T - The type expected.
Returns
The value returned from the method.
FirstOrdinalResultsAsync
Reads the first column from every record and returns the results as a list.. DBNull values are converted to null.
Returns
The list of transformed records.
FirstOrdinalResultsAsync``1
Reads the first column from every record.. DBNull values are converted to null.
Returns
The enumerable of casted values.
IterateReaderAsync(handler, token)
Iterates asynchronously and will stop iterating if canceled.
| Name | Description |
|---|---|
| handler | System.Action{System.Data.IDataRecord} The active IDataRecord is passed to this handler. |
| token | System.Nullable{System.Threading.CancellationToken} An optional cancellation token. |
Returns
IterateReaderAsyncWhile(predicate)
Iterates asynchronously until the handler returns false. Then cancels.
| Name | Description |
|---|---|
| predicate | System.Func{System.Data.IDataRecord,System.Boolean} If true, the iteration continues. |
Returns
The task that completes when the iteration is done or the predicate evaluates false.
IterateReaderAsyncWhile(predicate)
Iterates asynchronously until the handler returns false. Then cancels.
| Name | Description |
|---|---|
| predicate | System.Func{System.Data.IDataRecord If true, the iteration continues. |
Returns
The task that completes when the iteration is done or the predicate evaluates false.
ResultsAsync``1(fieldMappingOverrides)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A task containing the list of results.
ResultsAsync``1(fieldMappingOverrides)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A task containing the list of results.
ResultsAsync``1(fieldMappingOverrides)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A task containing the list of results.
RetrieveAsync
Asynchronously iterates all records within the first result set using an IDataReader and returns the results.
Returns
The QueryResult that contains all the results and the column mappings.
RetrieveAsync(ordinals)
Asynchronously iterates all records within the current result set using an IDataReader and returns the desired results.
| Name | Description |
|---|---|
| ordinals | System.Collections.Generic.IEnumerable{System.Int32} The ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
RetrieveAsync(columnNames, normalizeColumnOrder)
Iterates all records within the first result set using an IDataReader and returns the desired results as a list of Dictionaries containing only the specified column values.
| Name | Description |
|---|---|
| columnNames | System.Collections.Generic.IEnumerable{System.String} The column names to select. |
| normalizeColumnOrder | System.Boolean Orders the results arrays by ordinal. |
Returns
The QueryResult that contains all the results and the column mappings.
RetrieveAsync(n, others)
Asynchronously iterates all records within the current result set using an IDataReader and returns the desired results.
| Name | Description |
|---|---|
| n | System.Int32 The first ordinal to include in the request to the reader for each record. |
| others | System.Int32[] The remaining ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
RetrieveAsync(c, others)
Iterates all records within the current result set using an IDataReader and returns the desired results.
| Name | Description |
|---|---|
| c | System.String The first column name to include in the request to the reader for each record. |
| others | System.String[] The remaining column names to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
TakeAsync``1(transform, count)
Asynchronously iterates a IDataReader and returns the each result until the count is met.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
| count | System.Int32 The maximum number of records before complete. |
Returns
The value from the transform.
ToListAsync``1(transform)
Asynchronously returns all records via a transform function.
| Name | Description |
|---|---|
| transform | System.Func{System.Data.IDataRecord,``0} The desired column names. |
Returns
A task containing the list of results.
ToTargetBlockAsync``1(transform, target)
Posts all transformed records to the provided target block. If .Complete is called on the target block, then the iteration stops.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| transform | System.Threading.Tasks.Dataflow.ITargetBlock{``0} The transform function to process each IDataRecord. |
| target | System.Func{System.Data.IDataRecord,``0} The target block to receive the records. |
Returns
A task that is complete once there are no more results.
Extensions
Core non-DB-specific extensions for building a command and retrieving data using best practices.
AddParameter(target, name, value, type, direction)
Shortcut for adding command parameter.
| Name | Description |
|---|---|
| target | System.Data.IDbCommand The command to add a parameter to. |
| name | System.String The name of the parameter. |
| value | System.Object The value of the parameter. |
| type | System.Data.DbType The DbType of the parameter. |
| direction | System.Data.ParameterDirection The direction of the parameter. |
Returns
The created IDbDataParameter.
AddParameter(target, name, value)
Shortcut for adding command parameter.
| Name | Description |
|---|---|
| target | System.Data.IDbCommand The command to add a parameter to. |
| name | System.String The name of the parameter. |
| value | System.Object The value of the parameter. |
Returns
The created IDbDataParameter.
AddParameterType(target, name, type, direction)
Shortcut for adding command a typed (non-input) parameter.
| Name | Description |
|---|---|
| target | System.Data.IDbCommand The command to add a parameter to. |
| name | System.String The name of the parameter. |
| type | System.Data.DbType The DbType of the parameter. |
| direction | System.Data.ParameterDirection The direction of the parameter. |
Returns
The created IDbDataParameter.
AsEnumerable(columns)
Generic enumerable extension for DataColumnCollection.
| Name | Description |
|---|---|
| columns | System.Data.DataColumnCollection The column collection. |
Returns
An enumerable of DataColumns.
AsEnumerable(rows)
Generic enumerable extension for DataRowCollection.
| Name | Description |
|---|---|
| rows | System.Data.DataRowCollection The row collection. |
Returns
An enumerable of DataRows.
AsEnumerable(reader, ordinals)
Enumerates all the remaining values of the current result set of a data reader. DBNull values are retained.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The reader to enumerate. |
| ordinals | System.Collections.Generic.IEnumerable{System.Int32} The limited set of ordinals to include. If none are specified, the returned objects will be empty. |
Returns
An enumeration of the values returned from a data reader.
AsEnumerable(reader, n, others)
Enumerates all the remaining values of the current result set of a data reader.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The reader to enumerate. |
| n | System.Int32 The first ordinal to include in the request to the reader for each record. |
| others | System.Int32[] The remaining ordinals to request from the reader for each record. |
Returns
An enumeration of the values returned from a data reader.
AsEnumerable(reader)
Enumerates all the remaining values of the current result set of a data reader. DBNull values are retained.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The reader to enumerate. |
Returns
An enumeration of the values returned from a data reader.
Command(target, command, type)
Creates an ExpressiveDbCommand for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | Open.Database.Extensions.IDbConnectionFactory{System.Data.Common.DbConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
| type | System.Data.CommandType The command type. |
Returns
The resultant ExpressiveDbCommand.
Command(target, command, type)
Creates an ExpressiveDbCommand for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | System.Func{System.Data.Common.DbConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
| type | System.Data.CommandType The command type. |
Returns
The resultant ExpressiveDbCommand.
CreateCommand(connection, type, commandText, secondsTimeout)
Shortcut for creating an DbCommand from any DbConnection.
| Name | Description |
|---|---|
| connection | System.Data.Common.DbConnection The connection to create a command from. |
| type | System.Data.CommandType The command type. Text, StoredProcedure, or TableDirect. |
| commandText | System.String The command text or stored procedure name to use. |
| secondsTimeout | System.Int32 The number of seconds to wait before the command times out. |
Returns
The created SqlCommand.
CreateCommand(connection, type, commandText, secondsTimeout)
Shortcut for creating an IDbCommand from any IDbConnection.
| Name | Description |
|---|---|
| connection | System.Data.IDbConnection The connection to create a command from. |
| type | System.Data.CommandType The command type. Text, StoredProcedure, or TableDirect. |
| commandText | System.String The command text or stored procedure name to use. |
| secondsTimeout | System.Int32 The number of seconds to wait before the command times out. |
Returns
The created SqlCommand.
CreateStoredProcedureCommand(connection, commandText, secondsTimeout)
Shortcut for creating an DbCommand from any DbConnection.
| Name | Description |
|---|---|
| connection | System.Data.Common.DbConnection The connection to create a command from. |
| commandText | System.String The command text or stored procedure name to use. |
| secondsTimeout | System.Int32 The number of seconds to wait before the command times out. |
Returns
The created SqlCommand.
CreateStoredProcedureCommand(connection, commandText, secondsTimeout)
Shortcut for creating an IDbCommand from any IDbConnection.
| Name | Description |
|---|---|
| connection | System.Data.IDbConnection The connection to create a command from. |
| commandText | System.String The command text or stored procedure name to use. |
| secondsTimeout | System.Int32 The number of seconds to wait before the command times out. |
Returns
The created SqlCommand.
DBNullToNull(values)
Any DBNull values are converted to null.
| Name | Description |
|---|---|
| values | System.Collections.Generic.IEnumerable{System.Object} The source values. |
Returns
The converted enumerable.
DBNullToNull(values)
Returns a copy of this array with any DBNull values converted to null.
| Name | Description |
|---|---|
| values | System.Object[] The source values. |
Returns
A new array containing the results with.
DequeueEach``1(System.Collections.Generic.Queue{``0})
Useful extension for dequeuing items from a queue. Not thread safe but queueing/dequeueing items in between items is supported.
Type Parameters
- T - Return type of the source queue
Returns
An enumerable of the items contained within the queue.
ExecuteReader(command, handler, behavior)
Executes a reader on a command with a handler function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| handler | System.Action{System.Data.IDataReader} The handler function for each IDataRecord. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
ExecuteReader``1(command, transform, behavior)
Executes a reader on a command with a transform function.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataReader,``0} The transform function for each IDataRecord. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
Returns
The result of the transform.
First``1(command, transform)
Iterates an IDataReader and returns the first result through a transform funciton. Throws if none.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
FirstOrDefault``1(command, transform)
Iterates an IDataReader and returns the first result through a transform funciton. Returns default(T) if none.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
FirstOrdinalResults(System.Data.IDataReader)
Reads the first column from every record and returns the results as a list.. DBNull values are converted to null.
Returns
The list of values.
FirstOrdinalResults(System.Data.IDbCommand)
Reads the first column from every record.. DBNull values are converted to null.
Returns
The enumerable of casted values.
FirstOrdinalResults``1(System.Data.Common.DbDataReader)
Reads the first column from every record.. DBNull values are converted to null.
Returns
The enumerable of casted values.
FirstOrdinalResults``1(System.Data.IDbCommand)
Reads the first column from every record.. DBNull values are converted to null.
Returns
The enumerable of casted values.
FirstOrdinalResultsAsync(System.Data.Common.DbCommand)
Reads the first column from every record and returns the results.. DBNull values are converted to null.
Returns
The list of values.
FirstOrdinalResultsAsync(System.Data.Common.DbDataReader)
Reads the first column from every record and returns the results.. DBNull values are converted to null.
Returns
The list of values.
FirstOrdinalResultsAsync``1(System.Data.Common.DbCommand)
Reads the first column from every record.. DBNull values are converted to null.
Returns
The enumerable of casted values.
ForEach(reader, handler)
Iterates all records from an IDataReader.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to iterate. |
| handler | System.Action{System.Data.IDataRecord} The handler function for each IDataRecord. |
ForEachAsync(command, handler, token)
Asynchronously iterates all records from an IDataReader.
| Name | Description |
|---|---|
| command | System.Data.Common.DbCommand The DbCommand to generate a reader from. |
| handler | System.Action{System.Data.IDataRecord} The handler function for each IDataRecord. |
| token | System.Nullable{System.Threading.CancellationToken} Optional cancellatio token. |
ForEachAsync(reader, handler)
Iterates all records from an IDataReader.
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The IDataReader to iterate. |
| handler | System.Action{System.Data.IDataRecord} The handler function for each IDataRecord. |
ForEachAsync(reader, handler)
Iterates all records from an IDataReader.
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The IDataReader to iterate. |
| handler | System.Func{System.Data.IDataRecord,System.Threading.Tasks.Task} The handler function for each IDataRecord. |
GetDataTypeNames(reader)
Returns all the data type names for the columns of current result set.
| Name | Description |
|---|---|
| reader | System.Data.IDataRecord The reader to get data type names from. |
Returns
The array of data type names.
GetMatchingOrdinals(record, columnNames, sort)
Returns an array of name to ordinal mappings.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to query the ordinals from. |
| columnNames | System.Collections.Generic.IEnumerable{System.String} The requested column names. |
| sort | System.Boolean If true, will order the results by ordinal ascending. |
Returns
GetNames(record)
Returns all the column names for the current result set.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The reader to get column names from. |
Returns
The array of column names.
GetOrdinalMapping(record, columnNames, sort)
Returns an array of name to ordinal mappings.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to query the ordinals from. |
| columnNames | System.Collections.Generic.IEnumerable{System.String} The requested column names. |
| sort | System.Boolean If true, will order the results by ordinal ascending. |
Returns
GetOrdinalMapping(record)
Returns the (name,ordinal) mapping for current result set.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The reader to get column names from. |
Returns
The array of mappings.
GetValuesFromOrdinals(record, ordinals)
Produces a selective set of column values based upon the desired ordinal positions.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to query. |
| ordinals | System.Int32[] The set of ordinals to query. |
Returns
An array of values matching the ordinal positions requested.
Iterate``1(reader, transform)
Iterates all records from an IDataReader.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to iterate. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
An enumerable used to iterate the results.
IterateReader(command, handler)
Iterates a reader on a command with a handler function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| handler | System.Action{System.Data.IDataRecord} The handler function for each IDataRecord. |
IterateReader(command, behavior, handler)
Iterates a reader on a command with a handler function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
| handler | System.Action{System.Data.IDataRecord} The handler function for each IDataRecord. |
IterateReader``2(command, behavior, transform, selector)
Executes a reader on a command with a transform function.
Type Parameters
- TEntity - The return type of the transform function applied to each record.
- TResult - The type returned by the selector.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function for each IDataRecord. |
| selector | System.Func{System.Collections.Generic.IEnumerable{``0},``1} Provides an IEnumerable |
Returns
The result of the transform.
IterateReader``2(command, transform, selector)
Executes a reader on a command with a transform function.
Type Parameters
- TEntity - The return type of the transform function applied to each record.
- TResult - The type returned by the selector.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function for each IDataRecord. |
| selector | System.Func{System.Collections.Generic.IEnumerable{``0},``1} Provides an IEnumerable |
Returns
The result of the transform.
IterateReaderAsyncWhile(command, predicate, behavior)
Asynchronously iterates an IDataReader on a command while the predicate returns true.
| Name | Description |
|---|---|
| command | System.Data.Common.DbCommand The DbCommand to generate a reader from. |
| predicate | System.Func{System.Data.IDataRecord,System.Boolean} The hanlder function that processes each IDataRecord and decides if iteration should continue. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
IterateReaderAsyncWhile(command, predicate, behavior)
Asynchronously iterates an IDataReader on a command while the predicate returns true.
| Name | Description |
|---|---|
| command | System.Data.Common.DbCommand The DbCommand to generate a reader from. |
| predicate | System.Func{System.Data.IDataRecord The hanlder function that processes each IDataRecord and decides if iteration should continue. |
| behavior | System.Threading.Tasks.Task{System.Boolean}} The command behavior for once the command the reader is complete. |
IterateReaderWhile(command, predicate, behavior)
Iterates an IDataReader on a command while the predicate returns true.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| predicate | System.Func{System.Data.IDataRecord,System.Boolean} The hanlder function that processes each IDataRecord and decides if iteration should continue. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
IterateWhile(reader, predicate)
Iterates an IDataReader while the predicate returns true.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to iterate. |
| predicate | System.Func{System.Data.IDataRecord,System.Boolean} The hanlder function that processes each IDataRecord and decides if iteration should continue. |
ReplaceDBNullWithNull(values)
Replaces any DBNull values in the array with null;
| Name | Description |
|---|---|
| values | System.Object[] The source values. |
Returns
The converted enumerable.
Results``1(reader, fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Results``1(reader, fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Results``1(reader, fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Results``1(command, fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The command to generate a reader from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Results``1(command, fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The command to generate a reader from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Results``1(command, fieldMappingOverrides)
Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The command to generate a reader from. |
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
ResultsAsync``1(reader, fieldMappingOverrides)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The IDataReader to read results from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A task containing the list of results.
ResultsAsync``1(reader, fieldMappingOverrides)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The IDataReader to read results from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A task containing the list of results.
ResultsAsync``1(reader, fieldMappingOverrides)
Asynchronously returns all records and iteratively attempts to map the fields to type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The IDataReader to read results from. |
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
A task containing the list of results.
ResultsFromDataTable``1(reader, fieldMappingOverrides)
Loads all data into a DataTable before Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
ResultsFromDataTable``1(command, fieldMappingOverrides)
Loads all data into a DataTable before Iterates each record and attempts to map the fields to type T. Data is temporarily stored (buffered in entirety) in a queue of dictionaries before applying the transform for each iteration.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The command to generate a reader from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
The enumerable to pull the transformed results from.
Retrieve(reader, ordinals)
Iterates all records within the current result set using an IDataReader and returns the desired results as a list of Dictionaries containing only the specified column values. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| ordinals | System.Collections.Generic.IEnumerable{System.Int32} The ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(reader, columnNames)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| columnNames | System.Collections.Generic.IEnumerable{System.String} The column names to select. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(reader, n, others)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| n | System.Int32 The first ordinal to include in the request to the reader for each record. |
| others | System.Int32[] The remaining ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(reader, c, others)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
| c | System.String The first column name to include in the request to the reader for each record. |
| others | System.String[] The remaining column names to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(reader)
Iterates all records within the first result set using an IDataReader and returns the results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to read results from. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(command, ordinals)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate the reader from. |
| ordinals | System.Collections.Generic.IEnumerable{System.Int32} The ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(command, columnNames)
Iterates all records within the first result set using an IDataReader and returns the desired results as a list of Dictionaries containing only the specified column values. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate the reader from. |
| columnNames | System.Collections.Generic.IEnumerable{System.String} The column names to select. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(command, n, others)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate the reader from. |
| n | System.Int32 The first ordinal to include in the request to the reader for each record. |
| others | System.Int32[] The remaining ordinals to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(command, c, others)
Iterates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate the reader from. |
| c | System.String The first column name to include in the request to the reader for each record. |
| others | System.String[] The remaining column names to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
Retrieve(command)
Iterates all records within the first result set using an IDataReader and returns the results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate the reader from. |
Returns
The QueryResult that contains all the results and the column mappings.
RetrieveAsync(reader, ordinals)
Asynchronously enumerates all the remaining values of the current result set of a data reader. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The reader to enumerate. |
| ordinals | System.Collections.Generic.IEnumerable{System.Int32} The limited set of ordinals to include. If none are specified, the returned objects will be empty. |
Returns
The QueryResult that contains a buffer block of the results and the column mappings.
RetrieveAsync(reader, columnNames, normalizeColumnOrder)
Asynchronously enumerates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The IDataReader to read results from. |
| columnNames | System.Collections.Generic.IEnumerable{System.String} The column names to select. |
| normalizeColumnOrder | System.Boolean Orders the results arrays by ordinal. |
Returns
The QueryResult that contains all the results and the column mappings.
RetrieveAsync(reader, n, others)
Asynchronously enumerates all the remaining values of the current result set of a data reader. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The reader to enumerate. |
| n | System.Int32 The first ordinal to include in the request to the reader for each record. |
| others | System.Int32[] The remaining ordinals to request from the reader for each record. |
Returns
The QueryResult that contains a buffer block of the results and the column mappings.
RetrieveAsync(reader, c, others)
Asynchronously enumerates all records within the current result set using an IDataReader and returns the desired results. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The IDataReader to read results from. |
| c | System.String The first column name to include in the request to the reader for each record. |
| others | System.String[] The remaining column names to request from the reader for each record. |
Returns
The QueryResult that contains all the results and the column mappings.
RetrieveAsync(reader)
Asynchronously enumerates all the remaining values of the current result set of a data reader. DBNull values are left unchanged (retained).
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The reader to enumerate. |
Returns
The QueryResult that contains a buffer block of the results and the column mappings.
Single``1(command, transform)
Iterates an IDataReader and returns the first result through a transform funciton. Throws if none or more than one entry.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
SingleOrDefault``1(command, transform)
Iterates an IDataReader and returns the first result through a transform funciton. Returns default(T) if none. Throws if more than one entry.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The value from the transform.
Skip``1(command, count, transform)
Iterates an IDataReader and skips the first number of results defined by the count.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| count | System.Int32 The number of records to skip. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The results from the transform after the skip count.
SkipThenTake``1(command, skip, take, transform)
Iterates an IDataReader and skips by the skip parameter returns the maximum remaining defined by the take parameter.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| skip | System.Int32 The number of entries to skip before starting to take results. |
| take | System.Int32 The maximum number of records to return. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The results from the skip, transform and take operation.
StoredProcedure(target, command)
Creates an ExpressiveDbCommand with command type set to StoredProcedure for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | Open.Database.Extensions.IDbConnectionFactory{System.Data.Common.DbConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
Returns
The resultant ExpressiveDbCommand.
StoredProcedure(target, command)
Creates an ExpressiveDbCommand with command type set to StoredProcedure for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | System.Func{System.Data.Common.DbConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
Returns
The resultant ExpressiveDbCommand.
Take``1(command, count, transform)
Iterates an IDataReader and returns the first number of results defined by the count.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| count | System.Int32 The maximum number of records to return. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
The results from the transform limited by the take count.
To``1(table, fieldMappingOverrides, clearSourceTable)
Loads all data into a queue before iterating (dequeing) the results as type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| table | System.Data.DataTable The DataTable to read from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
| clearSourceTable | System.Boolean Clears the source table before providing the enumeration. |
Returns
An enumerable used to iterate the results.
To``1(table, fieldMappingOverrides, clearSourceTable)
Loads all data into a queue before iterating (dequeing) the results as type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| table | System.Data.DataTable The DataTable to read from. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
| clearSourceTable | System.Boolean Clears the source table before providing the enumeration. |
Returns
An enumerable used to iterate the results.
To``1(table, fieldMappingOverrides)
Loads all data into a queue before iterating (dequeing) the results as type T.
Type Parameters
- T - The model type to map the values to (using reflection).
| Name | Description |
|---|---|
| table | System.Data.DataTable The DataTable to read from. |
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An enumerable used to iterate the results.
ToArray``1(reader, transform)
Shortcut for .Iterate(transform).ToArray();
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to iterate. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
An array of the transformed results.
ToArray``1(command, behavior, transform)
Iterates all records using an IDataReader and returns the desired results as a list.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A list of all results.
ToArray``1(command, transform)
Iterates all records using an IDataReader and returns the desired results as a list.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A list of all results.
ToDataTable(reader)
Loads all remaining data from an IDataReader into a DataTable.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to load data from. |
Returns
The resultant DataTable.
ToDataTable(command, behavior)
Loads all data from a command through an IDataReader into a DataTable.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
Returns
The resultant DataTable.
ToDataTables(command, behavior)
Loads all data from a command through an IDataReader into a DataTables. Calls .NextResult() to check for more results.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
Returns
The resultant list of DataTables.
ToDictionary(record, columnMap)
Returns the specified column data of IDataRecord as a Dictionary. DBNull values are converted to null.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to extract values from. |
| columnMap | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.Int32,System.String}} The column ids and resultant names to query. |
Returns
The resultant Dictionary of values.
ToDictionary(record, columnNames)
Returns the specified column data of IDataRecord as a Dictionary. DBNull values are converted to null.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to extract values from. |
| columnNames | System.Collections.Generic.IEnumerable{System.String} The column names to query. |
Returns
The resultant Dictionary of values.
ToDictionary(record, columnMap)
Returns the specified column data of IDataRecord as a Dictionary. DBNull values are converted to null.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to extract values from. |
| columnMap | System.Collections.Generic.IEnumerable{System.ValueTuple{System.Int32,System.String}} The column ids and resultant names to query. |
Returns
The resultant Dictionary of values.
ToDictionary(record, columnNames)
Returns the specified column data of IDataRecord as a Dictionary. DBNull values are converted to null.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to extract values from. |
| columnNames | System.Collections.Generic.ISet{System.String} The column names to query. |
Returns
The resultant Dictionary of values.
ToDictionary(record, columnNames)
Returns the specified column data of IDataRecord as a Dictionary. DBNull values are converted to null.
| Name | Description |
|---|---|
| record | System.Data.IDataRecord The IDataRecord to extract values from. |
| columnNames | System.String[] The column names to query. If none specified, the result will contain all columns. |
Returns
The resultant Dictionary of values.
ToList``1(reader, transform)
Shortcut for .Iterate(transform).ToList();
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to iterate. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A list of the transformed results.
ToList``1(command, behavior, transform)
Iterates all records using an IDataReader and returns the desired results as a list.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| behavior | System.Data.CommandBehavior The command behavior for once the command the reader is complete. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A list of all results.
ToList``1(command, transform)
Iterates all records using an IDataReader and returns the desired results as a list.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A list of all results.
ToListAsync``1(command, transform)
Asynchronously iterates all records using an IDataReader and returns the desired results as a list.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.Common.DbCommand The DbCommand to generate a reader from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A task containing a list of all results.
ToListAsync``1(reader, transform)
Asynchronously iterates all records using an IDataReader and returns the desired results as a list.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The SqlDataReader to read from. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
Returns
A task containing a list of all results.
ToTargetBlock``1(reader, transform, target)
Iterates an IDataReader through the transform function and posts each record to the target block.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| reader | System.Data.IDataReader The IDataReader to iterate. |
| transform | System.Threading.Tasks.Dataflow.ITargetBlock{``0} The transform function for each IDataRecord. |
| target | System.Func{System.Data.IDataRecord,``0} The target block to receivethe results. |
ToTargetBlock``1(command, target, transform)
Iterates an IDataReader through the transform function and posts each record to the target block.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.IDbCommand The IDataReader to iterate. |
| target | System.Threading.Tasks.Dataflow.ITargetBlock{``0} The target block to receive the results. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function for each IDataRecord. |
ToTargetBlockAsync``1(command, target, transform)
Asynchronously iterates an IDataReader and through the transform function and posts each record it to the target block.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| command | System.Data.Common.DbCommand The DbCommand to generate a reader from. |
| target | System.Threading.Tasks.Dataflow.ITargetBlock{``0} The target block to receive the results. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function for each IDataRecord. |
ToTargetBlockAsync``1(reader, target, transform)
Asynchronously iterates an IDataReader and through the transform function and posts each record it to the target block.
Type Parameters
- T - The return type of the transform function.
| Name | Description |
|---|---|
| reader | System.Data.Common.DbDataReader The SqlDataReader to read from. |
| target | System.Threading.Tasks.Dataflow.ITargetBlock{``0} The target block to receive the results. |
| transform | System.Func{System.Data.IDataRecord,``0} The transform function to process each IDataRecord. |
IDbConnectionFactory
Simplified interface with IDbConnection as the generic type.
Create
Generates a new connection of declared generic type.
Returns
IDbConnectionFactory`1
Base interface for creating connections. Useful for dependency injection.
Type Parameters
- TConnection - The actual connection type.
Create
Generates a new connection of declared generic type.
Returns
QueryResult`1
A container for data reader results that also provides the column names and other helpful data methods.
Constructor(ordinals, names, result)
| Name | Description |
|---|---|
| ordinals | System.Int32[] The ordinal values requested |
| names | System.String[] The column names requested. |
| result | `0 The result. |
ColumnCount
The number of columns.
Names
The column names requested.
Ordinals
The ordinal values requested.
Result
The values requested. A Queue is used since values are typically used first in first out and dequeuing results helps reduced redunant memory usage.
QueryResultExtensions
A set of extensions for getting column data from a QueryResult.
AsMappedDictionaries(source)
Returns an enumerable that dequeues the results and returns a column mapped dictionary for each entry. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Collections.Generic.IEnumerable{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
Returns
An enumerable that dequeues the results and returns a column mapped dictionary for each entry
AsMappedDictionaries(source)
Returns an enumerable that dequeues the results and returns a column mapped dictionary for each entry. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Threading.Tasks.Dataflow.ISourceBlock{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
Returns
An block that dequeues the results and returns a column mapped dictionary for each entry
AsMappedDictionaries(source)
Returns an enumerable that dequeues the results and returns a column mapped dictionary for each entry. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | System.Threading.Tasks.Task{Open.Database.Extensions.QueryResult{System.Collections.Generic.IEnumerable{System.Object[]}}} The query result. Typically produced by a .Retrieve method. |
Returns
An enumerable that dequeues the results and returns a column mapped dictionary for each entry
DequeueAs``1(source, fieldMappingOverrides)
Returns an enumerable that dequeues the results and attempts to map the fields to type T. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Collections.Generic.Queue{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An enumerable that dequeues the results and returns an entity of type T.
DequeueAs``1(source, fieldMappingOverrides)
Returns an enumerable that dequeues the results and attempts to map the fields to type T. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Collections.Generic.Queue{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An enumerable that dequeues the results and returns an entity of type T.
DequeueAs``1(source, fieldMappingOverrides)
Returns an enumerable that dequeues the results and attempts to map the fields to type T. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | System.Threading.Tasks.Task{Open.Database.Extensions.QueryResult{System.Collections.Generic.Queue{System.Object[]}}} The query result. Typically produced by a .Retrieve method. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An enumerable that dequeues the results and returns an entity of type T.
DequeueAs``1(source, fieldMappingOverrides)
Returns an enumerable that dequeues the results and attempts to map the fields to type T. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | System.Threading.Tasks.Task{Open.Database.Extensions.QueryResult{System.Collections.Generic.Queue{System.Object[]}}} The query result. Typically produced by a .Retrieve method. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An enumerable that dequeues the results and returns an entity of type T.
DequeueAsMappedDictionaries(source)
Returns an enumerable that dequeues the results and returns a column mapped dictionary for each entry. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Collections.Generic.Queue{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
Returns
An enumerable that dequeues the results and returns a column mapped dictionary for each entry
DequeueAsMappedDictionaries(source)
Returns an enumerable that dequeues the results and returns a column mapped dictionary for each entry. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | System.Threading.Tasks.Task{Open.Database.Extensions.QueryResult{System.Collections.Generic.Queue{System.Object[]}}} The query result. Typically produced by a .Retrieve method. |
Returns
An enumerable that dequeues the results and returns a column mapped dictionary for each entry
To``1(source, fieldMappingOverrides)
Returns a block that attempts to map the fields to type T. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Threading.Tasks.Dataflow.ISourceBlock{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.Collections.Generic.KeyValuePair{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An block that dequeues the results and returns a column mapped dictionary for each entry
To``1(source, fieldMappingOverrides)
Returns a block that attempts to map the fields to type T. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Threading.Tasks.Dataflow.ISourceBlock{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
| fieldMappingOverrides | System.Collections.Generic.IEnumerable{System.ValueTuple{System.String,System.String}} An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An block that dequeues the results and returns a column mapped dictionary for each entry
To``1(source, fieldMappingOverrides)
Returns a block that attempts to map the fields to type T. DBNull values are converted to null.
| Name | Description |
|---|---|
| source | Open.Database.Extensions.QueryResult{System.Threading.Tasks.Dataflow.ISourceBlock{System.Object[]}} The query result. Typically produced by a .Retrieve method. |
| fieldMappingOverrides | System.ValueTuple{System.String,System.String}[] An optional override map of field names to column names where the keys are the property names, and values are the column names. |
Returns
An block that dequeues the results and returns a column mapped dictionary for each entry
ExpressiveSqlCommand
A specialized for SqlClient abstraction for executing commands on a database using best practices and simplified expressive syntax.
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{System.Data.SqlClient.SqlConnection} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | Open.Database.Extensions.ExpressiveCommandBase{System.Data.SqlClient.SqlConnection,System.Data.SqlClient.SqlCommand,System.Data.SqlDbType,Open.Database.Extensions.SqlClient.ExpressiveSqlCommand}.Param[] The list of params |
Constructor(connFactory, type, command, params)
| Name | Description |
|---|---|
| connFactory | Open.Database.Extensions.IDbConnectionFactory{System.Data.SqlClient.SqlConnection} The factory to generate connections from. |
| type | System.Data.CommandType The command type>. |
| command | System.String The SQL command. |
| params | System.Collections.Generic.List{Open.Database.Extensions.ExpressiveCommandBase{System.Data.SqlClient.SqlConnection,System.Data.SqlClient.SqlCommand,System.Data.SqlDbType,Open.Database.Extensions.SqlClient.ExpressiveSqlCommand}.Param} The list of params |
AddParams(command)
Handles adding the list of parameters to a new command.
| Name | Description |
|---|---|
| command | System.Data.SqlClient.SqlCommand |
Extensions
SqlClient extensions for building a command and retrieving data using best practices.
AddParameter(target, name, value, type, direction)
Shortcut for adding command parameter.
| Name | Description |
|---|---|
| target | System.Data.SqlClient.SqlCommand The command to add a parameter to. |
| name | System.String The name of the parameter. |
| value | System.Object The value of the parameter. |
| type | System.Data.SqlDbType The DbType of the parameter. |
| direction | System.Data.ParameterDirection The direction of the parameter. |
Returns
The created IDbDataParameter.
AddParameterType(target, name, type)
Shortcut for adding command a typed (non-input) parameter.
| Name | Description |
|---|---|
| target | System.Data.IDbCommand The command to add a parameter to. |
| name | System.String The name of the parameter. |
| type | System.Data.SqlDbType The SqlDbType of the parameter. |
Returns
The created IDbDataParameter.
AddParameterType(target, name, type, direction)
Shortcut for adding command a typed (non-input) parameter.
| Name | Description |
|---|---|
| target | System.Data.SqlClient.SqlCommand The command to add a parameter to. |
| name | System.String The name of the parameter. |
| type | System.Data.SqlDbType The SqlDbType of the parameter. |
| direction | System.Data.ParameterDirection The direction of the parameter. |
Returns
The created IDbDataParameter.
Command(target, command, type)
Creates an ExpressiveSqlCommand for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | Open.Database.Extensions.IDbConnectionFactory{System.Data.SqlClient.SqlConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
| type | System.Data.CommandType The command type. |
Returns
The resultant ExpressiveSqlCommand.
Command(target, command, type)
Creates an ExpressiveSqlCommand for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | System.Func{System.Data.SqlClient.SqlConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
| type | System.Data.CommandType The command type. |
Returns
The resultant ExpressiveSqlCommand.
CreateCommand(connection, type, commandText, secondsTimeout)
Shortcut for creating an SqlCommand from any SqlConnection.
| Name | Description |
|---|---|
| connection | System.Data.SqlClient.SqlConnection The connection to create a command from. |
| type | System.Data.CommandType The command type. Text, StoredProcedure, or TableDirect. |
| commandText | System.String The command text or stored procedure name to use. |
| secondsTimeout | System.Int32 The number of seconds to wait before the command times out. |
Returns
The created SqlCommand.
CreateStoredProcedureCommand(connection, commandText, secondsTimeout)
Shortcut for creating an SqlCommand from any SqlConnection.
| Name | Description |
|---|---|
| connection | System.Data.SqlClient.SqlConnection The connection to create a command from. |
| commandText | System.String The command text or stored procedure name to use. |
| secondsTimeout | System.Int32 The number of seconds to wait before the command times out. |
Returns
The created SqlCommand.
StoredProcedure(target, command)
Creates an ExpressiveSqlCommand with command type set to StoredProcedure for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | Open.Database.Extensions.IDbConnectionFactory{System.Data.SqlClient.SqlConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
Returns
The resultant ExpressiveSqlCommand.
StoredProcedure(target, command)
Creates an ExpressiveSqlCommand with command type set to StoredProcedure for subsequent configuration and execution.
| Name | Description |
|---|---|
| target | System.Func{System.Data.SqlClient.SqlConnection} The connection factory to generate a commands from. |
| command | System.String The command text or stored procedure name to use. |
Returns
The resultant ExpressiveSqlCommand.
SqlConnectionFactory
Default SqlConnectionFactory for generating SqlConnections.
Constructor(factory)
Default injectable connection factory constructor.
| Name | Description |
|---|---|
| factory | System.Func{System.Data.SqlClient.SqlConnection} The factory that generates the connections. |
Constructor(connectionString)
Default injectable connection factory constructor that accepts a connection string.
| Name | Description |
|---|---|
| connectionString | System.String Required connection string value. |