TryToFind() public method

public TryToFind ( Type type, object id ) : object
type System.Type
id object
return object
Example #1
0
        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);
        }