Interface IRepository
Interface defines the functionality of a data repository.
Namespace: Cireson.Core.Interfaces.DataAccess
Assembly: Cireson.Core.Interfaces.dll
Syntax
public interface IRepository
Remarks
Admin, 8/24/2017.
Methods
View SourceAdd<TEntity>(TEntity)
Adds an entity object to the repository such that it will be inserted into the database when SaveChanges is called.
Declaration
TEntity Add<TEntity>(TEntity entity)
where TEntity : class, IPlatformEntity
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity object to be added. |
Returns
Type | Description |
---|---|
TEntity | Returns the entity object that was added to the repository. |
Type Parameters
Name | Description |
---|---|
TEntity | The type of entity object to be added. |
Remarks
The entity Id will not be assigned automatically if null until SaveChanges is called.
DataPumpSaveChangesAsync()
Fast saving things --not yet implemented.
Declaration
Task<int> DataPumpSaveChangesAsync()
Returns
Type | Description |
---|---|
Task<System.Int32> | An asynchronous result that yields the data pump save changes. |
DbSet<TEntity>()
Fetches the entity DBSet from the repository. Read/Write.
Declaration
IDbSet<TEntity> DbSet<TEntity>()
where TEntity : class, IPlatformEntity
Returns
Type | Description |
---|---|
IDbSet<TEntity> | Returns an interface to the set of entities that entity object was assigned to. |
Type Parameters
Name | Description |
---|---|
TEntity | The entity object to be updated. |
Delete<TEntity>(TEntity)
Deletes an entity object from the repository such that it will be deleted from the database when SaveChanges is called. Note that the entity must exist in the context in some other state before this method is calle.
Declaration
void Delete<TEntity>(TEntity entity)
where TEntity : class, IPlatformEntity
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity object to be deleted. |
Type Parameters
Name | Description |
---|---|
TEntity | The type of entity object to be deleted. |
DeleteById<TEntity>(Nullable<Int64>)
Deletes an entity by id without loading it from the db.
Declaration
void DeleteById<TEntity>(long? id)
where TEntity : class, IPlatformEntity
Parameters
Type | Name | Description |
---|---|---|
System.Nullable<System.Int64> | id | . |
Type Parameters
Name | Description |
---|---|
TEntity | . |
Get<TEntity>()
Fetches an entity from the repository. Read only.
Declaration
IQueryable<TEntity> Get<TEntity>()
where TEntity : class, IPlatformEntity
Returns
Type | Description |
---|---|
IQueryable<TEntity> | Returns a queryable entity object. |
Type Parameters
Name | Description |
---|---|
TEntity | The entity object to be fetched. |
GetDataContext()
Retrieves the IDataContext Instance for this repository.
Declaration
IDataContext GetDataContext()
Returns
Type | Description |
---|---|
IDataContext | The data context. |
GetSingleEntity<TEntity>(Guid)
Fetches a single entity with the given guid.
Declaration
TEntity GetSingleEntity<TEntity>(Guid guid)
where TEntity : class, IPlatformEntity
Parameters
Type | Name | Description |
---|---|---|
Guid | guid | The guid of the entity to be fetched. |
Returns
Type | Description |
---|---|
TEntity | Returns the entitiy with the specified guid or null if it was not found. |
Type Parameters
Name | Description |
---|---|
TEntity | The entity object to be fetched. |
GetSingleEntity<TEntity>(Int64)
Fetches a single entity with the given ID.
Declaration
TEntity GetSingleEntity<TEntity>(long id)
where TEntity : class, IPlatformEntity
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | id | The id of the entity to be fetched. |
Returns
Type | Description |
---|---|
TEntity | Returns the entity with the specified ID or null if it was not found. |
Type Parameters
Name | Description |
---|---|
TEntity | The entity object to be fetched. |
RemoveRelationship<TEntity, TRelatedEntity>(TEntity, Expression<Func<TEntity, Object>>, TRelatedEntity[])
Removes the relationship.
Declaration
void RemoveRelationship<TEntity, TRelatedEntity>(TEntity entity, Expression<Func<TEntity, object>> propertyExpression, params TRelatedEntity[] relatedEntities)
where TEntity : class, IPlatformEntity where TRelatedEntity : class, IPlatformEntity
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity object to be deleted. |
Expression<Func<TEntity, System.Object>> | propertyExpression | The property expression. |
TRelatedEntity[] | relatedEntities | A variable-length parameters list containing related entities. |
Type Parameters
Name | Description |
---|---|
TEntity | Type of the entity. |
TRelatedEntity | Type of the related entity. |
RemoveRelationship<TEntity, TRelatedEntity>(TEntity, String, TRelatedEntity[])
Removes the relationship.
Declaration
void RemoveRelationship<TEntity, TRelatedEntity>(TEntity entity, string propertyName, params TRelatedEntity[] relatedEntities)
where TEntity : class, IPlatformEntity where TRelatedEntity : class, IPlatformEntity
Parameters
Type | Name | Description |
---|---|---|
TEntity | entity | The entity object to be deleted. |
System.String | propertyName | Name of the property. |
TRelatedEntity[] | relatedEntities | A variable-length parameters list containing related entities. |
Type Parameters
Name | Description |
---|---|
TEntity | Type of the entity. |
TRelatedEntity | Type of the related entity. |
SaveChanges()
Saves pending changes made to the repository.
Declaration
int SaveChanges()
Returns
Type | Description |
---|---|
System.Int32 | Returns the number of objects written to the repository. |
SaveChangesAsync()
Asynchronously saves pending changes made to the repository.
Declaration
Task<int> SaveChangesAsync()
Returns
Type | Description |
---|---|
Task<System.Int32> | Returns the number of objects written to the repository. |