Class SelectCache
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.
Inheritance
Inherited Members
Namespace: TimeCockpit.Data.Database
Assembly: TimeCockpit.Data.dll
Syntax
public class SelectCache
Methods
CreateInstance()
creates a new instance of the select cache.
Declaration
public static SelectCache CreateInstance()
Returns
Type | Description |
---|---|
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.
Declaration
public EntityObject GetOrAdd(ModelEntityBase entity, Guid guid, Func<Guid, EntityObject> factory)
Parameters
Type | Name | Description |
---|---|---|
ModelEntityBase | entity | The entity type of the object. |
System.Guid | guid | The object id to add. |
System.Func<System.Guid, EntityObject> | factory | The factory method to call. |
Returns
Type | Description |
---|---|
EntityObject | Returns the added EntityObject. |
TryGetValue(ModelEntityBase, Guid, out EntityObject)
Performs a 2 stage lookup to the cache structure to retrieve the entity object.
Declaration
public bool TryGetValue(ModelEntityBase entity, Guid guid, out EntityObject entityObject)
Parameters
Type | Name | Description |
---|---|---|
ModelEntityBase | entity | The entity type the requested entity object is of. |
System.Guid | guid | The unique identifier of the object. |
EntityObject | entityObject | The result entity object. |
Returns
Type | Description |
---|---|
System.Boolean | Returns true if an entity object was found, false otherwise. |