Class EntitySet<T>
An entity set representing all entities of type T in the entity store.
public class EntitySet<T> : IEntitySet<T>, IFrozenQuery<T>, IEntityQuery<T>, IEntityQuery, IDisposable, ILazy<ILoadedSet<T>>, ILazy, ILoadedSet<T>, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, INotifyCollectionChanged, IProperty, IOwned, IHasChanges where T : IEntity<T>
Type Parameters
T
- Inheritance
-
EntitySet<T>
- Implements
-
IEntitySet<T>IFrozenQuery<T>IEntityQuery<T>ILazy<ILoadedSet<T>>ILoadedSet<T>IEnumerable<T>
- Inherited Members
- Extension Methods
-
EntityQueryExtensions.OrderBy<TSource, TKey>(IEntityQuery<TSource>, Expression<Func<TSource, TKey>>)EntityQueryExtensions.SingleAsync<T>(IEntityQuery<T>, Expression<Func<T, bool>>, CancellationToken?)EntityQueryExtensions.SumAsync<T>(IEntityQuery<T>, Expression<Func<T, decimal>>, CancellationToken?)
Constructors
EntitySet(IEntityContext, int)
public EntitySet(IEntityContext context, int count)
Parameters
contextIEntityContextcountint
Properties
CacheState
Whether data was loaded from the entity cache and, if so, whether it's up to date.
public ResultState CacheState { get; }
Property Value
Count
Gets the number of elements that were present when the query was frozen.
public int Count { get; }
Property Value
ElementType
Gets the type of the element(s) that are returned when the expression tree associated with this instance of IEntityQuery is executed.
public Type ElementType { get; }
Property Value
Expression
Gets the expression tree that is associated with the instance of IEntityQuery.
public Expression Expression { get; }
Property Value
IsPresent
Whether the data is loaded. Never performs IO.
public bool IsPresent { get; }
Property Value
Metadata
Owner's property descriptor (if any owner).
public PropertyInfo? Metadata { get; }
Property Value
Parent
Owner (if any).
public EntityKernel? Parent { get; }
Property Value
Provider
Gets the query provider that is associated with this data source.
public IEntityQueryProvider Provider { get; }
Property Value
Methods
Add(T)
public void Add(T item)
Parameters
itemT
AddAsync(T, CancellationToken?)
public Task AddAsync(T item, CancellationToken? cancellationToken = null)
Parameters
itemTcancellationTokenCancellationToken?
Returns
AddRange(IEnumerable<T>)
public void AddRange(IEnumerable<T> items)
Parameters
itemsIEnumerable<T>
AddRangeAsync(IEnumerable<T>, CancellationToken?)
public Task AddRangeAsync(IEnumerable<T> items, CancellationToken? cancellationToken = null)
Parameters
itemsIEnumerable<T>cancellationTokenCancellationToken?
Returns
AsLoaded()
Asserts that the property object is loaded and returns it; never performs I/O.
public ILoadedSet<T> AsLoaded()
Returns
- ILoadedSet<T>
Exceptions
- InvalidOperationException
Thrown if the property or any reference along the path to it is unloaded.
AsUnloaded()
Assert that the set is unloaded and treat it as a datastore query.
public IEntityQuery<T> AsUnloaded()
Returns
- IEntityQuery<T>
Remarks
An empty set is always considered loaded. Calling this method on an empty set will cause an exception to be thrown.
Exceptions
- InvalidOperationException
Thrown if the set is partially or entirely loaded.
Clear()
public void Clear()
ClearAsync(CancellationToken?)
public Task ClearAsync(CancellationToken? cancellationToken = null)
Parameters
cancellationTokenCancellationToken?
Returns
Contains(T)
public bool Contains(T item)
Parameters
itemT
Returns
ContainsAsync(T, CancellationToken?)
public Task<bool> ContainsAsync(T item, CancellationToken? cancellationToken = null)
Parameters
itemTcancellationTokenCancellationToken?
Returns
CreateAsync(IEntityContext, CancellationToken?)
Count entities in the table and create a set. Does not load all entities.
public static Task<EntitySet<T>> CreateAsync(IEntityContext context, CancellationToken? ct = null)
Parameters
contextIEntityContextctCancellationToken?
Returns
CreateCachedAsync(IEntityContext, CancellationToken?)
Count entities in the table and create a set. Does not load all entities. Uses counts from the cache if possible.
public static Task<EntitySet<T>> CreateCachedAsync(IEntityContext context, CancellationToken? ct = null)
Parameters
contextIEntityContextctCancellationToken?
Returns
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
EnsurePresent()
[Obsolete("Synchronous reads are a legacy feature which will be removed eventually. Use await, LoadAsync() or EnsurePresentAsync().")]
public void EnsurePresent()
EnsurePresentAsync(CancellationToken?)
public Task EnsurePresentAsync(CancellationToken? cancellationToken = null)
Parameters
cancellationTokenCancellationToken?
Returns
GetAwaiter()
Awaiting the lazy is equivalent to calling LoadAsync(CancellationToken?); eager-loaded data completes synchronously.
public TaskAwaiter<ILoadedSet<T>> GetAwaiter()
Returns
GetEnumerator()
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
HasChanges()
true if the current value differs from its original
public bool HasChanges()
Returns
IsInMemory()
Returns true if the frozen query is at least partially-loaded. In-memory queries should not be transformed into ReadOperations for batching.
public bool IsInMemory()
Returns
LoadAsync(CancellationToken?)
Loads the property object in at most one read batch.
public Task<ILoadedSet<T>> LoadAsync(CancellationToken? cancellationToken = null)
Parameters
cancellationTokenCancellationToken?
Returns
- Task<ILoadedSet<T>>
LoadAsync(RelationshipPath[], CancellationToken?)
Loads the property object and related data in at most one read batch.
public Task<ILoadedSet<T>> LoadAsync(RelationshipPath[] includeRelationships, CancellationToken? cancellationToken = null)
Parameters
includeRelationshipsRelationshipPath[]cancellationTokenCancellationToken?
Returns
- Task<ILoadedSet<T>>
LoadCachedAsync(RequestOptions?, CancellationToken?)
Loads the property object and related data in at most one read batch. Uses the entity cache if possible. If the result was stale, ValueChanged will be raised after validation.
public Task<ILoadedSet<T>> LoadCachedAsync(RequestOptions? options = null, CancellationToken? cancellationToken = null)
Parameters
optionsRequestOptionscancellationTokenCancellationToken?
Returns
- Task<ILoadedSet<T>>
LoadCachedAsync(RequestOptions?, RelationshipPath[], CancellationToken?)
Loads the property object and related data in at most one read batch. Uses the entity cache if possible. If the result was stale, ValueChanged will be raised after validation.
public Task<ILoadedSet<T>> LoadCachedAsync(RequestOptions? options, RelationshipPath[] includes, CancellationToken? cancellationToken = null)
Parameters
optionsRequestOptionsincludesRelationshipPath[]cancellationTokenCancellationToken?
Returns
- Task<ILoadedSet<T>>
MarkUnchanged()
update original data so that it's no longer considered changed
public void MarkUnchanged()
NeedsSave()
true if the value has non-derived changes, ones made deliberately by a user or business logic
public bool NeedsSave()
Returns
Remove(T)
public void Remove(T item)
Parameters
itemT
RemoveAsync(T, CancellationToken?)
public Task RemoveAsync(T item, CancellationToken? cancellationToken = null)
Parameters
itemTcancellationTokenCancellationToken?
Returns
RemoveRange(IEnumerable<T>)
public void RemoveRange(IEnumerable<T> items)
Parameters
itemsIEnumerable<T>
RemoveRangeAsync(IEnumerable<T>, CancellationToken?)
public Task RemoveRangeAsync(IEnumerable<T> items, CancellationToken? cancellationToken = null)
Parameters
itemsIEnumerable<T>cancellationTokenCancellationToken?
Returns
ReplaceAll(IEnumerable<T>)
public void ReplaceAll(IEnumerable<T> items)
Parameters
itemsIEnumerable<T>
ReplaceAllAsync(IEnumerable<T>, CancellationToken?)
public Task ReplaceAllAsync(IEnumerable<T> items, CancellationToken? cancellationToken = null)
Parameters
itemsIEnumerable<T>cancellationTokenCancellationToken?
Returns
SaveAsync(CancellationToken?)
public Task<SaveResult> SaveAsync(CancellationToken? ct = null)
Parameters
Returns
Events
CollectionChanged
Occurs when the collection changes.
public event NotifyCollectionChangedEventHandler? CollectionChanged