Class CloudStorageDbSet<TEntity>
- Namespace
- CloudStorageORM.Repositories
- Assembly
- CloudStorageORM.dll
Lightweight query and enumeration wrapper for entities stored through IStorageProvider.
public class CloudStorageDbSet<TEntity> : IQueryable<TEntity>, IEnumerable<TEntity>, IQueryable, IEnumerable, IAsyncEnumerable<TEntity> where TEntity : class
Type Parameters
TEntityEntity type represented by this set.
- Inheritance
-
CloudStorageDbSet<TEntity>
- Implements
-
IQueryable<TEntity>IEnumerable<TEntity>IAsyncEnumerable<TEntity>
- Inherited Members
Constructors
CloudStorageDbSet(IStorageProvider)
Lightweight query and enumeration wrapper for entities stored through IStorageProvider.
public CloudStorageDbSet(IStorageProvider storageProvider)
Parameters
storageProviderIStorageProvider
Properties
ElementType
Gets the CLR element type represented by this queryable set.
public Type ElementType { get; }
Property Value
Expression
Gets the LINQ expression associated with this queryable wrapper.
public Expression Expression { get; }
Property Value
Provider
Gets the LINQ provider used to satisfy queryable operations.
public IQueryProvider Provider { get; }
Property Value
Methods
FirstOrDefaultAsync(Expression<Func<TEntity, bool>>, CancellationToken)
Returns the first entity matching the supplied predicate, or null when no match exists.
public Task<TEntity?> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate, CancellationToken cancellationToken = default)
Parameters
predicateExpression<Func<TEntity, bool>>Predicate used to filter entities in memory.
cancellationTokenCancellationTokenToken used to cancel the asynchronous enumeration.
Returns
Examples
var user = await dbSet.FirstOrDefaultAsync(x => x.Id == 42);
GetAsyncEnumerator(CancellationToken)
Returns an asynchronous enumerator over the cached entity list.
public IAsyncEnumerator<TEntity> GetAsyncEnumerator(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenToken used to cancel the asynchronous enumeration.
Returns
- IAsyncEnumerator<TEntity>
An asynchronous enumerator for the current entity snapshot.
Examples
await foreach (var user in dbSet)
{
Console.WriteLine(user);
}
GetEnumerator()
Returns a synchronous enumerator over the cached entity list.
public IEnumerator<TEntity> GetEnumerator()
Returns
- IEnumerator<TEntity>
An enumerator over the currently cached entities, or an empty enumerator if the set has not been materialized yet.
ToListAsync(CancellationToken)
Loads all entities into memory and caches the result for subsequent queries.
public Task<List<TEntity>> ToListAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenToken used to cancel the asynchronous enumeration.
Returns
Examples
var users = await dbSet.ToListAsync();