Table of Contents

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

TEntity

Entity type represented by this set.

Inheritance
CloudStorageDbSet<TEntity>
Implements
IQueryable<TEntity>
IEnumerable<TEntity>
Inherited Members

Constructors

CloudStorageDbSet(IStorageProvider)

Lightweight query and enumeration wrapper for entities stored through IStorageProvider.

public CloudStorageDbSet(IStorageProvider storageProvider)

Parameters

storageProvider IStorageProvider

Properties

ElementType

Gets the CLR element type represented by this queryable set.

public Type ElementType { get; }

Property Value

Type

Expression

Gets the LINQ expression associated with this queryable wrapper.

public Expression Expression { get; }

Property Value

Expression

Provider

Gets the LINQ provider used to satisfy queryable operations.

public IQueryProvider Provider { get; }

Property Value

IQueryProvider

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

predicate Expression<Func<TEntity, bool>>

Predicate used to filter entities in memory.

cancellationToken CancellationToken

Token used to cancel the asynchronous enumeration.

Returns

Task<TEntity>

The first matching entity, or null if no entity matches.

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

cancellationToken CancellationToken

Token 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

cancellationToken CancellationToken

Token used to cancel the asynchronous enumeration.

Returns

Task<List<TEntity>>

A snapshot of the stored entities.

Examples

var users = await dbSet.ToListAsync();