ICommonRepository<TEntity> Interface

The common interface for repositories supporting D3ORM. 


namespace KLO128.D3ORM.Common.Abstract
{
    public interface ICommonRepository<TEntity> where TEntity : class
}

Assembly

KLO128.D3ORM.Common.Abstract

Base Types

Object

Type Parameters

TEntity : class

Properties

None

Methods

AddAsChild<TParent>(..) 1/2


void AddAsChild<TParent>(TParent parent, Expression<Func<TParent, IEnumerable<TEntity>>> prop, TEntity entity) where TParent : class; 

Description

Adds the child entity instance to the database and to its parentcollection instance (assignment to the prop) ("one to many" relation). 

Return Type

void

Type Parameters

TParent : class

Parameters

# Name Type Description Default Value
1. parentTParentparent entity, which the entity is aggregated to
2. propExpression<Func<TParent, IEnumerable<TEntity>>>The collection property that the entity is added to.
3. entityTEntityentity to add

 

AddAsChild<TParent>(..) 2/2


void AddAsChild<TParent>(TParent parent, Expression<Func<TParent, TEntity?>> prop, TEntity entity) where TParent : class; 

Description

Adds the child entity instance to the database and to its parent instance (assignment to the prop) ("many to one" relation). 

Return Type

void

Type Parameters

TParent : class

Parameters

# Name Type Description Default Value
1. specificationTParentparent entity, which the entity is aggregated to
2. delayAfterTaskStartExpression<Func<TParent, TEntity>>The property that the entity is assigned to.
3. entityTEntityentity to add

 

BulkDelete(..)


void BulkDelete(ISpecification<TEntity> specification, int delayAfterTaskStart = 300, int? commandTimeout = null); 

Description

Calls BulkDeleteAsync() and waits for a certain of time specified by the delayAfterTaskStart to avoid disposing of the repository before an anonymous connection is created. 

Return Type

void

Parameters

# Name Type Description Default Value
1. specification[ISpecification<TEntity>](./Common-Abstract-Library%20ISpecification-TEntity.md)query specification for selecting data to delete
2. delayAfterTaskStartintamount of time to wait after task start 300
3. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

BulkDeleteAsync(..)


Task BulkDeleteAsync(ISpecification<TEntity> specification, int? commandTimeout = null); 

Description

Deletes all the rows given from the specification query asynchronously. An anonymous connection is created, so it will finish the job even if the request lifetime and all its services' lifetimes are over. 

Return Type

Task

Parameters

# Name Type Description Default Value
1. specification[ISpecification<TEntity>](./Common-Abstract-Library%20ISpecification-TEntity.md)query specification for selecting data to delete
2. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

BulkUpdateAsync(..)


Task BulkUpdateAsync<TProperty>(ISpecification<TEntity> specification, Expression<Func<TEntity, TProperty>> prop, TProperty value, int? commandTimeout = null); 
Task BulkUpdateAsync<TProp1, TProp2>(ISpecification<TEntity> specification, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, int? commandTimeout = null); 
Task BulkUpdateAsync<TProp1, TProp2, TProp3>(ISpecification<TEntity> specification, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, int? commandTimeout = null); 
Task BulkUpdateAsync<TProp1, TProp2, TProp3, TProp4>(ISpecification<TEntity> specification, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4, int? commandTimeout = null); 
Task BulkUpdateAsync<TProp1, TProp2, TProp3, TProp4, TProp5>(ISpecification<TEntity> specification, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4, Expression<Func<TEntity, TProp5>> prop5, TProp5 value5, int? commandTimeout = null); 

Description

Updates all the rows given from the specification query asynchronously. An anonymous connection is created, so it will finish the job even if the request lifetime and all its services' lifetimes are over. 

 

Return Type

Task

Parameters

# Name Type Description Default Value
1. specification[ISpecification<TEntity>](./Common-Abstract-Library%20ISpecification-TEntity.md)query specification for selecting data to update
2. prop1Expression<Func<TEntity, TProp1>>property to update
3. value1TProp1value to assign
4. opt. prop2Expression<Func<TEntity, TProp2>>property to update
5. opt. value2TProp2value to assign
6. opt. prop3Expression<Func<TEntity, TProp3>>property to update
7. opt. value3TProp3value to assign
8. opt. prop4Expression<Func<TEntity, TProp4>>property to update
9. opt. value4TProp4value to assign
10. opt. prop5Expression<Func<TEntity, TProp5>>property to update
11. opt. value5TProp5value to assign
12. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

CountAvgMinMaxSum(..) 1/2


List<object> CountAvgMinMaxSum(ISpecificationWithParams<TEntity> specification, int? commandTimeout = null); 

Description

Computes COUNT, AVG, MIN, MAX, SUM aggregate functions according to the specification

Use this overload if you do not have a special TResultDto type for this specificationThe result type will then be the Expando object type, which is convertible into IDictionary<string, object?>

Property names with computing aggregate function have this format: SHORTCUT_PropertyName, shortcuts are: CNT, AVG, MIN, MAX, SUM. 

Return Type

List<object>

Parameters

# Name Type Description Default Value
1. specification[ISpecification<TEntity>](./Common-Abstract-Library%20ISpecification-TEntity.md)query specification to compute results upon
2. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

CountAvgMinMaxSum<TResultDto>(..) 2/2


List<TResultDto> CountAvgMinMaxSum<TResultDto>(ISpecificationWithParams<TResultDto> specification, int? commandTimeout = null) where TResultDto : class, new(); 

Description

Computes COUNT, AVG, MIN, MAX, SUM aggregate functions according to the specification

Property names with computing aggregate function have this format: SHORTCUT_PropertyName, shortcuts are: CNT, AVG, MIN, MAX, SUM. 

Return Type

List<TResultDto>

Type Parameters

TResultDto : class, new()

Parameters

# Name Type Description Default Value
1. specification[ISpecification<TResultDto>](./Common-Abstract-Library%20ISpecification-TEntity.md)query specification to compute results upon
2. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

CountRows(..)


int CountRows(ISpecification<TEntity> specification); 

Description

Returns the number of rows of the top TEntity instance (without aggregation duplicities) in the query defined by the specification

Return Type

int

Parameters

# Name Type Description Default Value
1. specification[ISpecification<TEntity>](./Common-Abstract-Library%20ISpecification-TEntity.md)query specification to count rows upon

DeleteFromParent<TParent>(..) 1/2


void DeleteFromParent<TParent>(TParent parent, Expression<Func<TParent, IEnumerable<TEntity>>> prop, TEntity entity) where TParent : class; 

Description

Deletes the child entity instance from the database and from its parent collection instance (removes the entity item from the prop) ("one to many" relation). 

Return Type

void

Type Parameters

TParent : class

Parameters

# Name Type Description Default Value
1. parentTParentparent entity, which the entity is aggregated to
2. propExpression<Func<TParent, IEnumerable<TEntity>>>The collection property that the entity is disposed from.
3. entityTEntityentity to delete

 

DeleteFromParent<TParent>(..) 2/2


void DeleteFromParent<TParent>(TParent parent, Expression<Func<TParent, TEntity?>> prop, TEntity entity) where TParent : class; 

Description

Deletes the child entity instance from the database and from its parent instance (the prop is set to null) ("many to one" relation). 

Return Type

void

Type Parameters

TParent : class

Parameters

# Name Type Description Default Value
1. parentTParentparent entity, which the entity is aggregated to
2. propExpression<Func<TParent, TEntity>>The property that the entity is disposed from.
3. entityTEntityentity to delete

 

ExecuteNonQueryCommand(..)


List<TResult> ExecuteStoredCompute<TResult>(string storedProcedureName, IEnumerable<DbParameter> parameters, List<string?>? columnAsIdentifiers = null, int? commandTimeout = null) where TResult : class, new(); 

Description

Formats parameters (if defined) and executes a non-query command... 

Return Type

void

Parameters

# Name Type Description Default Value
1. commandTextstringcommand text
params parametersobject[]parameters object[0]

 

ExecuteNonQueryStoredProcedure(..)


List<TResult> ExecuteStoredCompute<TResult>(string storedProcedureName, IEnumerable<DbParameter> parameters, List<string?>? columnAsIdentifiers = null, int? commandTimeout = null) where TResult : class, new(); 

Description

Executes a non-query stored procedure... 

Return Type

void

Parameters

# Name Type Description Default Value
1. storedProcedureNamestringstored procedure name
2. parametersIEnumerable<DbParameter>parameters
3. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

ExecuteStoredCompute<TResult>(..)


List<TResult> ExecuteStoredCompute<TResult>(string storedProcedureName, IEnumerable<DbParameter> parameters, List<string?>? columnAsIdentifiers = null, int? commandTimeout = null) where TResult : class, new(); 

Description

Executes a stored procedure query containing computing aggregate functions: COUNT, AVG, MIN, MAX, SUM. (Aggregation is possible if the correct column names are used.)

If you do not have a special TResult type for this storedProcedureName result use objectThe result type will then be the Expando object type, which is convertible into IDictionary<string, object?>

Return Type

List<TResult>

Type Parameters

TResult : class, new()

Parameters

# Name Type Description Default Value
1. storedProcedureNamestringname of stored procedure
2. parametersIEnumerable<DbParameter>stored procedure parameters
3. columnAsIdentifiersList<string?>?column as identifiers needed for non-debug mode query null
4. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

ExecuteStoredSelect(..) 1/2


List<TEntity> ExecuteStoredSelect(string storedProcedureName, IEnumerable<DbParameter> parameters, List<string?>? columnAsIdentifiers = null, int? commandTimeout = null); 

Description

Executes and maps a stored procedure query result to an aggregated list of TEntity(Aggregation is possible if the correct column names are used.)

Return Type

List<TEntity>

Parameters

# Name Type Description Default Value
1. storedProcedureNamestringname of stored procedure
2. parametersIEnumerable<DbParameter>stored procedure parameters
3. columnAsIdentifiersList<string?>?column as identifiers needed for non-debug mode query null
4. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

ExecuteStoredSelect<TResultDto>(..) 2/2


List<TResultDto> ExecuteStoredSelect<TResultDto>(string storedProcedureName, IEnumerable<DbParameter> parameters, List<string?>? columnAsIdentifiers = null, int? commandTimeout = null) where TResultDto : class, new(); 

Description

Executes and maps a stored procedure query result to an aggregated list of TResultDto(Aggregation is possible if the correct column names are used.)

Return Type

List<TResultDto>

Type Parameters

TResultDto : class, new()

Parameters

# Name Type Description Default Value
1. storedProcedureNamestringname of stored procedure
2. parametersIEnumerable<DbParameter>stored procedure parameters
3. columnAsIdentifiersList<string?>?column as identifiers needed for non-debug mode query null
4. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

FindBy(..) 1/2


TEntity? FindBy(ISpecificationWithParams<TEntity> specification); 

Description

Queries the database by the specification and returns a single full object tree (aggregated) instance or null. 

Return Type

TEntity?

Parameters

# Name Type Description Default Value
1. specification[ISpecificationWithParams<TEntity>](./Common-Abstract-Library%20ISpecification-with-Params.md)query specification

 

FindBy<TResultDto>(..) 2/2


TResultDto? FindBy<TResultDto>(ISpecificationWithParams<TResultDto> specification) where TResultDto : class, new(); 

Description

Queries the database by the specification and returns a single full object tree (aggregated) instance or null. 

Return Type

TResultDto?

Type Parameters

TResultDto : class, new()

Parameters

# Name Type Description Default Value
1. specification[ISpecificationWithParams<TResultDto>](./Common-Abstract-Library%20ISpecification-with-Params.md)query specification

 

FindByIdSingle<TId>(..)


TEntity? FindByIdSingle<TId>(TId id) where TId : IComparable; 

Description

Tries to find the row of type TEntity by id and returns an entity without any child aggregations (single row containing primitive type values only) or null. 

Return Type

TEntity?

Type Parameters

TId : IComparable
#### Parameters
| # | Name | Type | Description | Default Value |
| --- |:------ |:----- |:---------------------- | ------------- |
| 1. |
id | TId | primary key identifier | |
 

### FindManyBy(..) 1/4


List<TEntity> FindManyBy(ISpecificationWithParams<TEntity> specification, int? commandTimeout = null); 

Description

Queries the database by the specification and returns a full object tree (aggregated) list of TEntity as a result. 

Return Type

List<TEntity>

Parameters

# Name Type Description Default Value
1. specification[ISpecificationWithParams<TEntity>](./Common-Abstract-Library%20ISpecification-with-Params.md)query specification
2. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

FindManyBy(..) 2/4


List<TEntity> FindManyBy(ISpecificationWithParams<TEntity> specification, bool countAllItems, out int? allItemsCount, int? skip, int? take, int? commandTimeout = null); 

Description

Queries the database by the specification and returns a full object tree (aggregated) list of TEntity as a result. Optionally, you can specify the number of top entity rows to skip and the number of top entity rows to take (included in a query result). 

Return Type

List<TEntity>

Parameters

# Name Type Description Default Value
1. specification[ISpecificationWithParams<TEntity>](./Common-Abstract-Library%20ISpecification-with-Params.md)query specification
2. countAllItemsboolSpecifies if to count all items or not.
3. out allItemsCountint?the number of all root items filtered if no skip and take applied
4. skipint?the number of top entity (only) rows to skip from the start of the query result
5. takeint?the number of top entity (only) rows to take from the result starting at the index following the last skipped row
6. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

FindManyBy<TResultDto>(..) 3/4


List<TResultDto> FindManyBy<TResultDto>(ISpecificationWithParams<TResultDto> specification, int? commandTimeout = null) where TResultDto : class, new(); 

Description

Queries the database by the specification and returns a full object tree (aggregated) list of TResultDto as a result. 

Return Type

List<TResultDto>

Type Parameters

TResultDto : class, new()

Parameters

# Name Type Description Default Value
1. specification[ISpecificationWithParams<TResultDto>](./Common-Abstract-Library%20ISpecification-with-Params.md)query specification
2. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

 

FindManyBy<TResultDto>(..) 4/4


List<TResultDto> FindManyBy<TResultDto>(ISpecificationWithParams<TResultDto> specification, bool countAllItems, out int? allItemsCount, int? skip, int? take, int? commandTimeout = null) where TResultDto : class, new(); 

Description

Queries the database by the specification and returns a full object tree (aggregated) list of TResultDto as a result. Optionally, you can specify the number of top entity rows to skip and the number of top entity rows to take (included in a query result). 

Return Type

List<TResultDto>

Type Parameters

TResultDto : class, new()

Parameters

# Name Type Description Default Value
1. specification[ISpecificationWithParams<TResultDto>](./Common-Abstract-Library%20ISpecification-with-Params.md)query specification
2. countAllItemsboolSpecifies if to count all items or not.
3. out allItemsCountint?the number of all root items filtered if no skip and take applied
4. skipint?the number of top entity (only) rows to skip from the start of the query result
5. takeint?the number of top entity (only) rows to take from the result starting at the index following the last skipped row
6. commandTimeoutint?command timeout (If null, then the default timeout is used.) null

ParameterizedInsert(..)


void ParameterizedInsert(TEntity entity, IDbCommand reuseableCommand, Func<IDataParameter> createEmptyParameter, bool includeId = false); 

Description

Quick insert using the same parameterized command. 

Return Type

void

Parameters

# Name Type Description Default Value
1. entityTEntityEntity you want to insert.
2. reuseableCommandIDbCommandCommand which is reused for repetitive insert. Create an empty command for the first time.
3. createEmptyParameterFunc<IDataParameter>Function to create an empty IDataParameter which is populated inside.
4. includeIdboolIf you want to include ID, you must ensure IDENTITY INSERT is on. false

 

SaveChanges()


void SaveChanges(); 

Description

Function for ORMs that tracks the database context state (D3ORM does nothing). 

Return Type

void

Parameters

# Name Type Description Default Value

 

UpdateEntity(..)


void UpdateEntity(TEntity entity); 

Description

Updates the whole single entity instance only (without any touch of any aggregation). 

Return Type

void

Parameters

# Name Type Description Default Value
1. entityTEntityentity to update

 

UpdateProperties(..)


void UpdateProperties<TProperty>(TEntity entity, Expression<Func<TEntity, TProperty>> prop, TProperty value); 
void UpdateProperties<TProp1, TProp2>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2); 
void UpdateProperties<TProp1, TProp2, TProp3>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3); 
void UpdateProperties<TProp1, TProp2, TProp3, TProp4>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4); 
void UpdateProperties<TProp1, TProp2, TProp3, TProp4, TProp5>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4, Expression<Func<TEntity, TProp5>> prop5, TProp5 value5); 
void UpdateProperties<TProp1, TProp2, TProp3, TProp4, TProp5, TProp6>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4, Expression<Func<TEntity, TProp5>> prop5, TProp5 value5, Expression<Func<TEntity, TProp6>> prop6, TProp6 value6); 
void UpdateProperties<TProp1, TProp2, TProp3, TProp4, TProp5, TProp6, TProp7>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4, Expression<Func<TEntity, TProp5>> prop5, TProp5 value5, Expression<Func<TEntity, TProp6>> prop6, TProp6 value6, Expression<Func<TEntity, TProp7>> prop7, TProp7 value7); 
void UpdateProperties<TProp1, TProp2, TProp3, TProp4, TProp5, TProp6, TProp7, TProp8>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4, Expression<Func<TEntity, TProp5>> prop5, TProp5 value5, Expression<Func<TEntity, TProp6>> prop6, TProp6 value6, Expression<Func<TEntity, TProp7>> prop7, TProp7 value7, Expression<Func<TEntity, TProp8>> prop8, TProp8 value8); 
void UpdateProperties<TProp1, TProp2, TProp3, TProp4, TProp5, TProp6, TProp7, TProp8, TProp9>(TEntity entity, Expression<Func<TEntity, TProp1>> prop1, TProp1 value1, Expression<Func<TEntity, TProp2>> prop2, TProp2 value2, Expression<Func<TEntity, TProp3>> prop3, TProp3 value3, Expression<Func<TEntity, TProp4>> prop4, TProp4 value4, Expression<Func<TEntity, TProp5>> prop5, TProp5 value5, Expression<Func<TEntity, TProp6>> prop6, TProp6 value6, Expression<Func<TEntity, TProp7>> prop7, TProp7 value7, Expression<Func<TEntity, TProp8>> prop8, TProp8 value8, Expression<Func<TEntity, TProp9?>> prop9, TProp9? value9); 

Description

Updates the specified properties of the entity instance by using the expression(s) (without any touch of any aggregation). 

Return Type

void

Type Parameters

TProp1... TProp9

Parameters

# Name Type Description Default Value
1. entityTEntityentity to update
2. prop1Expression<Func<TEntity, TProp1>>property to update
3. value1TProp1value to assign
4. opt. prop2Expression<Func<TEntity, TProp2>>property to update
5. opt. value2TProp2value to assign
6. opt. prop3Expression<Func<TEntity, TProp3>>property to update
7. opt. value3TProp3value to assign
8. opt. prop4Expression<Func<TEntity, TProp4>>property to update
9. opt. value4TProp4value to assign
10. opt. prop5Expression<Func<TEntity, TProp5>>property to update
11. opt. value5TProp5value to assign
12. opt. prop6Expression<Func<TEntity, TProp6>>property to update
13. opt. value6TProp6value to assign
14. opt. prop7Expression<Func<TEntity, TProp7>>property to update
15. opt. value7TProp7value to assign
16. opt. prop8Expression<Func<TEntity, TProp8>>property to update
17. opt. value8TProp8value to assign
18. opt. prop9Expression<Func<TEntity, TProp9?>>property to update
19. opt. value9TProp9?value to assign