1+ using System ;
12using System . Collections . Generic ;
23using System . Linq ;
34using System . Threading . Tasks ;
@@ -17,12 +18,19 @@ public class DefaultEntityRepository<TEntity>
1718 IEntityRepository < TEntity >
1819 where TEntity : class , IIdentifiable < int >
1920 {
21+ [ Obsolete ( "DbContext is no longer directly injected into the ctor. Use JsonApiContext.GetDbContextResolver() instead" ) ]
2022 public DefaultEntityRepository (
2123 DbContext context ,
2224 ILoggerFactory loggerFactory ,
2325 IJsonApiContext jsonApiContext )
2426 : base ( context , loggerFactory , jsonApiContext )
2527 { }
28+
29+ public DefaultEntityRepository (
30+ ILoggerFactory loggerFactory ,
31+ IJsonApiContext jsonApiContext )
32+ : base ( loggerFactory , jsonApiContext )
33+ { }
2634 }
2735
2836 public class DefaultEntityRepository < TEntity , TId >
@@ -35,6 +43,7 @@ public class DefaultEntityRepository<TEntity, TId>
3543 private readonly IJsonApiContext _jsonApiContext ;
3644 private readonly IGenericProcessorFactory _genericProcessorFactory ;
3745
46+ [ Obsolete ( "DbContext is no longer directly injected into the ctor. Use JsonApiContext.GetDbContextResolver() instead" ) ]
3847 public DefaultEntityRepository (
3948 DbContext context ,
4049 ILoggerFactory loggerFactory ,
@@ -47,6 +56,18 @@ public DefaultEntityRepository(
4756 _genericProcessorFactory = _jsonApiContext . GenericProcessorFactory ;
4857 }
4958
59+ public DefaultEntityRepository (
60+ ILoggerFactory loggerFactory ,
61+ IJsonApiContext jsonApiContext )
62+ {
63+ var contextResolver = jsonApiContext . GetDbContextResolver ( ) ;
64+ _context = contextResolver . GetContext ( ) ;
65+ _dbSet = contextResolver . GetDbSet < TEntity > ( ) ;
66+ _jsonApiContext = jsonApiContext ;
67+ _logger = loggerFactory . CreateLogger < DefaultEntityRepository < TEntity , TId > > ( ) ;
68+ _genericProcessorFactory = _jsonApiContext . GenericProcessorFactory ;
69+ }
70+
5071 public virtual IQueryable < TEntity > Get ( )
5172 {
5273 if ( _jsonApiContext . QuerySet ? . Fields != null && _jsonApiContext . QuerySet . Fields . Any ( ) )
0 commit comments