Interface INonUniqueIndex<TItem, TKey>
- Namespace
- AutoIndexCache
- Assembly
- AutoIndexCache.dll
Represents a non-unique index for cached items of the type TItem
.
public interface INonUniqueIndex<out TItem, TKey> where TItem : class
Type Parameters
TItem
The type of cache items indexed by the index.
TKey
The type of keys in the index.
Methods
ContainsKey(TKey?)
Determines whether this index contains the specified key.
bool ContainsKey(TKey? key)
Parameters
key
TKeyThe key to check.
Returns
- bool
True if this index contains the specified key; otherwise, false.
Examples
var cache = new AutoIndexCache();
cache.Items<User>().Fill(this.LoadUsers());
var hasGroup1Users = cache.Items<User>().NonUniqueIndex(a => a.GroupId).ContainsKey(1);
Exceptions
- ItemsListNotFilledYetException
This ItemsList<TItem> this index belongs to has not been filled with items yet.
GetItems(TKey?)
Gets all cached items of the type TItem
that satisfy the specified condition.
IReadOnlyList<out TItem> GetItems(TKey? condition)
Parameters
condition
TKeyThe condition the cache items to get must satisfy.
Returns
- IReadOnlyList<TItem>
A read-only list of cached items of the type
TItem
that satisfy the specified condition.
Examples
var cache = new AutoIndexCache();
cache.Items<User>().Fill(this.LoadUsers());
var usersOfGroup1 = cache.Items<User>().NonUniqueIndex(a => a.GroupId).GetItems(1);
var activeUsersOfGroup10 = cache.Items<User>().NonUniqueIndex(a => new { a.IsActive, a.GroupId}).GetItems(new { IsActive = true, GroupId = 10 });
Exceptions
- ItemsListNotFilledYetException
This ItemsList<TItem> this index belongs to has not been filled with items yet.
GetKeys()
Gets the keys in this index.
IReadOnlyCollection<TKey?> GetKeys()
Returns
- IReadOnlyCollection<TKey>
A read-only collection of the keys in this index.
Examples
var cache = new AutoIndexCache();
cache.Items<User>().Fill(this.LoadUsers());
var distinctGroupIds = cache.Items<User>().NonUniqueIndex(a => a.GroupId).GetKeys();
Exceptions
- ItemsListNotFilledYetException
This ItemsList<TItem> this index belongs to has not been filled with items yet.