CachedTable implement IEnumerable

This commit is contained in:
Фролов 2021-09-08 11:51:55 +05:00
parent 9d80c28c1b
commit 3c9718b0de

View File

@ -7,7 +7,8 @@ using System.Threading.Tasks;
namespace AsbCloudInfrastructure.Services.Cache namespace AsbCloudInfrastructure.Services.Cache
{ {
public class CacheTable<TEntity> where TEntity : class public class CacheTable<TEntity> : IEnumerable<TEntity>
where TEntity : class
{ {
private readonly DbContext context; private readonly DbContext context;
private (DateTime refreshDate, IEnumerable<object> entities) data; private (DateTime refreshDate, IEnumerable<object> entities) data;
@ -334,5 +335,9 @@ namespace AsbCloudInfrastructure.Services.Cache
cached.AddRange(dbEntities); cached.AddRange(dbEntities);
return dbEntities; return dbEntities;
} }
public IEnumerator<TEntity> GetEnumerator() => Where().GetEnumerator();
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() => GetEnumerator();
} }
} }