File tree 3 files changed +7
-15
lines changed
3 files changed +7
-15
lines changed Original file line number Diff line number Diff line change @@ -15,13 +15,11 @@ public class ContextGraphBuilder : IContextGraphBuilder
15
15
private bool _usesDbContext ;
16
16
public Link DocumentLinks { get ; set ; } = Link . All ;
17
17
18
- public ContextGraphBuilder ( )
19
- {
20
- _entities = new List < ContextEntity > ( ) ;
21
- }
22
-
23
18
public IContextGraph Build ( )
24
19
{
20
+ // this must be done at build so that call order doesn't matter
21
+ _entities . ForEach ( e => e . Links = GetLinkFlags ( e . EntityType ) ) ;
22
+
25
23
var graph = new ContextGraph ( )
26
24
{
27
25
Entities = _entities ,
@@ -41,8 +39,7 @@ public void AddResource<TResource>(string pluralizedTypeName) where TResource :
41
39
EntityName = pluralizedTypeName ,
42
40
EntityType = entityType ,
43
41
Attributes = GetAttributes ( entityType ) ,
44
- Relationships = GetRelationships ( entityType ) ,
45
- Links = GetLinkFlags ( entityType )
42
+ Relationships = GetRelationships ( entityType )
46
43
} ) ;
47
44
}
48
45
@@ -112,7 +109,7 @@ public void AddDbContext<T>() where T : DbContext
112
109
&& dbSetType . GetGenericTypeDefinition ( ) == typeof ( DbSet < > ) )
113
110
{
114
111
var entityType = dbSetType . GetGenericArguments ( ) [ 0 ] ;
115
-
112
+
116
113
VerifyEntityIsNotAlreadyDefined ( entityType ) ;
117
114
118
115
_entities . Add ( new ContextEntity
Original file line number Diff line number Diff line change @@ -29,8 +29,7 @@ public void BuildContextGraph<TContext>(Action<IContextGraphBuilder> builder)
29
29
30
30
public void BuildContextGraph ( Action < IContextGraphBuilder > builder )
31
31
{
32
- if ( builder == null )
33
- throw new ArgumentException ( "Cannot build non-EF context graph without an IContextGraphBuilder action" , nameof ( builder ) ) ;
32
+ if ( builder == null ) return ;
34
33
35
34
builder ( ContextGraphBuilder ) ;
36
35
Original file line number Diff line number Diff line change @@ -80,11 +80,7 @@ public void Page_Links_Can_Be_Disabled_Globally()
80
80
_pageManager . TotalRecords = 1 ;
81
81
_pageManager . CurrentPage = 1 ;
82
82
83
- _options . BuildContextGraph ( builder =>
84
- {
85
- builder . DocumentLinks = Link . None ;
86
- builder . AddResource < Model > ( "models" ) ;
87
- } ) ;
83
+ _options . BuildContextGraph ( builder => builder . DocumentLinks = Link . None ) ;
88
84
89
85
_jsonApiContextMock
90
86
. Setup ( m => m . ContextGraph )
You can’t perform that action at this time.
0 commit comments