public Store ( |
||
type | ||
id | object | |
entity | object | |
return | void |
public void Store(Type type, object id, object entity)
{
if (!cache.ContainsKey(type)) cache.Add(type, new Dictionary<string, object>());
cache[type][id.ToString()] = entity;
}
private TEntity CreateEntityFromValues <TEntity>(IDictionary <string, object> values) { var tableInfo = metaDataStore.GetTableInfoFor <TEntity>(); var cachedEntity = sessionLevelCache.TryToFind(typeof(TEntity), values[tableInfo.PrimaryKey.Name]); if (cachedEntity != null) { return((TEntity)cachedEntity); } var entity = Activator.CreateInstance <TEntity>(); Hydrate(tableInfo, entity, values); sessionLevelCache.Store(typeof(TEntity), values[tableInfo.PrimaryKey.Name], entity); return(entity); }