Data Reading Extensions
Extension class for executing aggregable queries.
namespace KLO128.D3ORM.Common.Extensions
{
public static class DtoExtensions
}
Assembly
KLO128.D3ORM.Common
Base Types
None
Properties
None
Methods
AggCompute<TEntityOrDTO, TResult>(..) 1/2
public static List<TResult> AggCompute<TEntityOrDTO, TResult>(this IDbConnection connection, ID3Context d3Context, Expression<Func<TResult, IEnumerable<TEntityOrDTO>>>? inverseRootCollection, Expression<Func<TEntityOrDTO, TResult>>? inverseRootDirectProperty, string cmdBatch, int? skip = null, int? take = null, CommandType commandType = CommandType.Text, IEnumerable<DbParameter>? spParameters = null, List<string?>? columnAsIdentifiers = null, int? commandTimeout = null) where TEntityOrDTO : class where TResult : class
Description
Executes computing aggregation functions according to the cmdBatch. (2 commands are generated from a specification if the skip and take option is used.) Returns a list of TResult containing the property names and the structure specified by the cmdBatch.
If you do not have a special TResult type for this cmdBatch use object. The result type will then be the Expando object type, which is convertible into IDictionary<string, object?>.
Properties with computing aggregate function have this format: SHORTCUT_PropertyName, shortcuts are: CNT, AVG, MIN, MAX, SUM.
It can be also used for stored procedures if you follow the column naming rules.
Return Type
List<TResult>
Type Parameters
- TEntityOrDTO : class
- TResult : class
Parameters
# | Name | Type | Description | Default Value |
---|---|---|---|---|
this | connection | IDbConnection | connection invoker | |
1. | d3Context | [ID3Context](./Common-Library%20ID3Context.md) | D3Context | |
2. | inverseRootCollection | Expression<Func<TResult, IEnumerable<TEntityOrDTO>>>? | "one to many" aggregation of the query root into the result root | |
3. | inverseRootDirectProperty | Expression<Func<TEntityOrDTO, TResult>>? | "many to one" aggregation of the query root into the result root | |
4. | cmdBatch | string | command string | |
5. | skip | int? | the number of top entity (only) rows to skip from the start of the query result | null |
6. | take | int? | the number of top entity (only) rows to take from the result starting at the index following the last skipped row | null |
7. | commandType | CommandType | command type (text or stored procedure) | CommandType.Text |
8. | spParameters | IEnumerable<DbParameter>? | The parameters used for stored procedure ONLY. | null |
9. | columnAsIdentifiers | List<string?>? | The column identifiers can be analyzed from the specification and this parameter can be null in that case, but it has to be defined for stored procedures if stored procedure has no corresponding AS identifiers. | null |
10 | commandTimeout | int? | command timeout (If null, then the default timeout is used.) | null |
AggCompute<TResult>(..) 2/2
public static List<TResult> AggCompute<TResult>(this IDbConnection connection, ID3Context d3Context, D3SQLAdapter sqlAdapter, int? skip = null, int? take = null, int? commandTimeout = null) where TResult : class
Description
Executes computing aggregation functions according to the sqlAdapter. Returns a list of TResult containing the property names and the structure specified by the sqlAdapter.
If you do not have a special TResult type for this sqlAdapter use object. The result type will then be the Expando object type, which is convertible into IDictionary<string, object?>.
Properties with computing aggregate function have this format: SHORTCUT_PropertyName, shortcuts are: CNT, AVG, MIN, MAX, SUM.
Return Type
List<TResult>
Type Parameters
TResult : class
Parameters
# | Name | Type | Description | Default Value |
---|---|---|---|---|
this | connection | IDbConnection | connection invoker | |
1. | d3Context | [ID3Context](./Common-Library%20ID3Context.md) | D3Context | |
2. | sqlAdapter | D3SQLAdapter | built SQL query adapter | |
3. | skip | int? | the number of top entity (only) rows to skip from the start of the query result | null |
4. | take | int? | the number of top entity (only) rows to take from the result starting at the index following the last skipped row | null |
5. | commandTimeout | int? | command timeout (If null, then the default timeout is used.) | null |
AggSelect<TEntityOrDTO, TResult>(..) 1/2
public static List<TResult> AggSelect<TEntityOrDTO, TResult>(this IDbConnection connection, ID3Context d3Context, Expression<Func<TResult, IEnumerable<TEntityOrDTO>>>? inverseRootCollection, Expression<Func<TEntityOrDTO, TResult>>? inverseRootDirectProperty, string cmdBatch, int? skip = null, int? take = null, CommandType commandType = CommandType.Text, IEnumerable<DbParameter>? spParameters = null, List<string?>? columnAsIdentifiers = null, int? commandTimeout = null) where TEntityOrDTO : class, new() where TResult : class, new()
Description
Queries the database by the cmdBatch. (2 commands are generated from a specification if the skip and take option is used.) Returns a full object tree (aggregated) list of TResult as a result.
Can be also used for stored procedures if you follow the column naming rules.
Return Type
List<TResult>
Type Parameters
- TEntityOrDTO : class
- TResult : class, new()
Parameters
# | Name | Type | Description | Default Value |
---|---|---|---|---|
this | connection | IDbConnection | connection invoker | |
1. | d3Context | [ID3Context](./Common-Library%20ID3Context.md) | D3Context | |
2. | inverseRootCollection | Expression<Func<TResult, IEnumerable<TEntityOrDTO>>>? | "one to many" aggregation of the query root into the result root | |
3. | inverseRootDirectProperty | Expression<Func<TEntityOrDTO, TResult>>? | "many to one" aggregation of the query root into the result root | |
4. | cmdBatch | string | command string | |
5. | skip | int? | the number of top entity (only) rows to skip from the start of the query result | null |
6. | take | int? | the number of top entity (only) rows to take from the result starting at the index following the last skipped row | null |
7. | commandType | CommandType | command type (text or stored procedure) | CommandType.Text |
8. | spParameters | IEnumerable<DbParameter>? | The parameters used for stored procedure ONLY. | null |
9. | columnAsIdentifiers | List<string?>? | The column identifiers can be analyzed from the specification and this parameter can be null in that case, but it has to be defined for stored procedures if stored procedure has no corresponding AS identifiers. | null |
10. | commandTimeout | int? | command timeout (If null, then the default timeout is used.) | null |
AggSelect<TResult>(..) 2/2
public static List<TResult> AggSelect<TResult>(this IDbConnection connection, ID3Context d3Context, D3SQLAdapter sqlAdapter, int? skip = null, int? take = null, int? commandTimeout = null) where TResult : class, new()
Description
Queries the database by the sqlAdapter. Returns a full object tree (aggregated) list of TResult as a result.
Return Type
List<TResult>
Type Parameters
TResult : class, new()
Parameters
# | Name | Type | Description | Default Value |
---|---|---|---|---|
this | connection | IDbConnection | connection invoker | |
1. | d3Context | [ID3Context](./Common-Library%20ID3Context.md) | D3Context | |
2. | sqlAdapter | D3SQLAdapter | built SQL query adapter | |
3. | skip | int? | the number of top entity (only) rows to skip from the start of the query result | null |
4. | take | int? | the number of top entity (only) rows to take from the result starting at the index following the last skipped row | null |
5. | commandTimeout | int? | command timeout (If null, then the default timeout is used.) | null |