@@ -32,7 +32,7 @@ public EntityResourceService(
32
32
IEntityRepository < TResource , TId > entityRepository ,
33
33
ILoggerFactory loggerFactory = null ,
34
34
IResourceHookExecutor hookExecutor = null ) :
35
- base ( jsonApiContext , entityRepository , loggerFactory , hookExecutor )
35
+ base ( jsonApiContext , entityRepository , hookExecutor , loggerFactory )
36
36
{ }
37
37
}
38
38
@@ -47,11 +47,28 @@ public class EntityResourceService<TResource, TEntity, TId> :
47
47
private readonly IResourceMapper _mapper ;
48
48
private readonly IResourceHookExecutor _hookExecutor ;
49
49
50
+ public EntityResourceService (
51
+ IJsonApiContext jsonApiContext ,
52
+ IEntityRepository < TEntity , TId > entityRepository ,
53
+ IResourceHookExecutor hookExecutor ,
54
+ ILoggerFactory loggerFactory = null )
55
+ {
56
+ // no mapper provided, TResource & TEntity must be the same type
57
+ if ( typeof ( TResource ) != typeof ( TEntity ) )
58
+ {
59
+ throw new InvalidOperationException ( "Resource and Entity types are NOT the same. Please provide a mapper." ) ;
60
+ }
61
+
62
+ _jsonApiContext = jsonApiContext ;
63
+ _entities = entityRepository ;
64
+ _hookExecutor = hookExecutor ;
65
+ _logger = loggerFactory ? . CreateLogger < EntityResourceService < TResource , TEntity , TId > > ( ) ;
66
+ }
67
+
50
68
public EntityResourceService (
51
69
IJsonApiContext jsonApiContext ,
52
70
IEntityRepository < TEntity , TId > entityRepository ,
53
- ILoggerFactory loggerFactory = null ,
54
- IResourceHookExecutor hookExecutor = null )
71
+ ILoggerFactory loggerFactory = null )
55
72
{
56
73
// no mapper provided, TResource & TEntity must be the same type
57
74
if ( typeof ( TResource ) != typeof ( TEntity ) )
@@ -61,7 +78,6 @@ public EntityResourceService(
61
78
62
79
_jsonApiContext = jsonApiContext ;
63
80
_entities = entityRepository ;
64
- _hookExecutor = hookExecutor ;
65
81
_logger = loggerFactory ? . CreateLogger < EntityResourceService < TResource , TEntity , TId > > ( ) ;
66
82
}
67
83
0 commit comments