コード例 #1
0
    /// <inheritdoc />
    public override TEntity?GetCached(TId id)
    {
        // get all from the cache -- and only the cache, then look for the entity
        DeepCloneableList <TEntity>?all = Cache.GetCacheItem <DeepCloneableList <TEntity> >(GetEntityTypeCacheKey());
        TEntity?entity = all?.FirstOrDefault(x => _entityGetId(x)?.Equals(id) ?? false);

        // see note in InsertEntities - what we get here is the original
        // cached entity, not a clone, so we need to manually ensure it is deep-cloned.
        return((TEntity?)entity?.DeepClone());
    }
コード例 #2
0
    /// <inheritdoc />
    public override TEntity?Get(TId?id, Func <TId?, TEntity?> performGet, Func <TId[]?, IEnumerable <TEntity>?> performGetAll)
    {
        // get all from the cache, then look for the entity
        IEnumerable <TEntity> all = GetAllCached(performGetAll);
        TEntity?entity            = all.FirstOrDefault(x => _entityGetId(x)?.Equals(id) ?? false);

        // see note in InsertEntities - what we get here is the original
        // cached entity, not a clone, so we need to manually ensure it is deep-cloned.
        return((TEntity?)entity?.DeepClone());
    }