Owneat Technical Guide main Help

Interface IRepository<T\>

Namespace: Common.Contracts
Assembly: Common.dll

Common.Contracts.IRepository%601 is an interface that get a generic parameter and give method definitions to query the database. The generic type have to implement the Common.Primitives.Entity class to be used.

public interface IRepository<T> where T : Entity

Type Parameters

T

Methods

Add\(T\)

Method that add an entity of type T in the database.

T Add(T entity)

Parameters

entity T

Returns

T

The added entity.

Delete\(T\)

Method that remove an entity of type T from the database.

void Delete(T entity)

Parameters

entity T

DeleteRange\(IEnumerable<T\>\)

Method that remove all passed entities of type T from the database.

void DeleteRange(IEnumerable<T> entities)

Parameters

entities IEnumerable <T\>

Exists\(Func<T, bool\>\)

Method that check if entity of type T in the database responds to a certain predicate.

bool Exists(Func<T, bool> predicate)

Parameters

predicate Func <T, bool \>

Returns

bool

True if the entities in database respond to the given predicate, false otherwise.

GetAllAsync\(\)

Method that get all entities of type T in the database.

Task<IEnumerable<T>> GetAllAsync()

Returns

Task < IEnumerable <T\>\>

System.Collections.Generic.IEnumerable%601 that contains all the elements.

GetByIdAsync\(Guid\)

Method that get an entity of type T in the database by it's System.Guid.

Task<T?> GetByIdAsync(Guid entityId)

Parameters

entityId Guid

Returns

Task <T?\>

Remarks

This method doesn't include related entities.

GetByIdAsyncWithConcurrency\(Guid\)

Method that get an entity of type T in the database by it's System.Guid. Remove entity tracking that was previously stored in it.

Task<T?> GetByIdAsyncWithConcurrency(Guid entityId)

Parameters

entityId Guid

Returns

Task <T?\>

Remarks

This method doesn't include related entities.

Update\(T\)

Method that update an entity of type T in the database.

void Update(T entity)

Parameters

entity T

UpdateRange\(IEnumerable<T\>\)

Method that update an entity of type T in the database.

void UpdateRange(IEnumerable<T> entities)

Parameters

entities IEnumerable <T\>

Last modified: 21 May 2024