using ZeroFramework.DeviceCenter.Domain.Entities; namespace ZeroFramework.DeviceCenter.Infrastructure.EntityFrameworks { public class IncludeRelatedPropertiesOptions { private readonly IDictionary _includeOptions = new Dictionary(); public Func, IQueryable> Get() where TEntity : BaseEntity { if (_includeOptions.TryGetValue(typeof(TEntity), out var value)) { return (Func, IQueryable>)value; } return query => query; } public void ConfigIncludes(Func, IQueryable> action) where TEntity : BaseEntity { _includeOptions.TryAdd(typeof(TEntity), action); } } }