Class SelectCache
- Namespace
- TimeCockpit.Data.Database
- Assembly
- TimeCockpit.Data.dll
class hiding the cache. A User can create such a cache and provide it as a lookup to queries, but cannot access the data itself.
A select cache represents entity objects that have been loaded previously.
Select methods from the DataContext take a select cache as an optional parameter. If such a parameter
is provided, the passed in cache is queried for pre-existing entity objects and those EntityObjects are reused without
further deserializing the relation.
Use the CreateInstance() method to create a fresh instance of the select cache. Passing the same instance to the select
methods will cause referenced entity objects to be the same object / reference identical.
public class SelectCache
- Inheritance
-
ObjectSelectCache
- Inherited Members
-
Object.ToString()Object.Equals(Object)Object.Equals(Object, Object)Object.ReferenceEquals(Object, Object)Object.GetHashCode()Object.GetType()Object.MemberwiseClone()
Methods
CreateInstance()
creates a new instance of the select cache.
public static SelectCache CreateInstance()
Returns
- SelectCache
Returns a new instance of the select cache.
GetOrAdd(ModelEntityBase, Guid, Func<Guid, EntityObject>)
Gets an entity object or calls the factory for a value to add.
public EntityObject GetOrAdd(ModelEntityBase entity, Guid guid, Func<Guid, EntityObject> factory)
Parameters
entityModelEntityBaseThe entity type of the object.
guidGuidThe object id to add.
factoryFunc<Guid, EntityObject>The factory method to call.
Returns
- EntityObject
Returns the added EntityObject.
TryGetValue(ModelEntityBase, Guid, out EntityObject)
Performs a 2 stage lookup to the cache structure to retrieve the entity object.
public bool TryGetValue(ModelEntityBase entity, Guid guid, out EntityObject entityObject)
Parameters
entityModelEntityBaseThe entity type the requested entity object is of.
guidGuidThe unique identifier of the object.
entityObjectEntityObjectThe result entity object.
Returns
- Boolean
Returns true if an entity object was found, false otherwise.