Class CloudStorageRepository<TEntity>
- Namespace
- CloudStorageORM.Repositories
- Assembly
- CloudStorageORM.dll
Repository wrapper that maps entity identifiers to provider-backed storage objects.
public class CloudStorageRepository<TEntity> : DbSet<TEntity>, IQueryable<TEntity>, IEnumerable<TEntity>, IQueryable, IEnumerable, IInfrastructure<IServiceProvider>, IListSource, ICloudStorageRepository<TEntity> where TEntity : class
Type Parameters
TEntityEntity type managed by this repository.
- Inheritance
-
DbSet<TEntity>CloudStorageRepository<TEntity>
- Implements
-
IQueryable<TEntity>IEnumerable<TEntity>ICloudStorageRepository<TEntity>
- Inherited Members
- Extension Methods
Constructors
CloudStorageRepository(IStorageProvider)
Repository wrapper that maps entity identifiers to provider-backed storage objects.
public CloudStorageRepository(IStorageProvider storageProvider)
Parameters
storageProviderIStorageProvider
Properties
EntityType
Gets the EF metadata for the repository entity type.
public override IEntityType EntityType { get; }
Property Value
Exceptions
- NotSupportedException
Always thrown because this repository does not expose custom EF metadata.
Methods
AddAsync(string, TEntity)
Adds a new entity to storage for the provided identifier.
public Task AddAsync(string id, TEntity entity)
Parameters
idstringEntity identifier used to build the storage path.
entityTEntityEntity instance to persist.
Returns
Examples
await repository.AddAsync("42", user);
FindAsync(string)
Finds an entity by identifier.
public Task<TEntity> FindAsync(string id)
Parameters
idstringEntity identifier used to locate the storage object.
Returns
- Task<TEntity>
The matching entity when found.
Examples
var user = await repository.FindAsync("42");
ListAsync()
Lists all entities available for this repository type.
public Task<List<TEntity>> ListAsync()
Returns
Examples
var users = await repository.ListAsync();
RemoveAsync(string)
Removes the entity identified by id from storage.
public Task RemoveAsync(string id)
Parameters
idstringEntity identifier used to locate the storage object.
Returns
Examples
await repository.RemoveAsync("42");
UpdateAsync(string, TEntity)
Updates an existing entity in storage for the provided identifier.
public Task UpdateAsync(string id, TEntity entity)
Parameters
idstringEntity identifier used to locate the storage object.
entityTEntityUpdated entity instance to persist.
Returns
Examples
await repository.UpdateAsync("42", user);