File tree Expand file tree Collapse file tree 3 files changed +7
-15
lines changed Expand file tree Collapse file tree 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
1515 private bool _usesDbContext ;
1616 public Link DocumentLinks { get ; set ; } = Link . All ;
1717
18- public ContextGraphBuilder ( )
19- {
20- _entities = new List < ContextEntity > ( ) ;
21- }
22-
2318 public IContextGraph Build ( )
2419 {
20+ // this must be done at build so that call order doesn't matter
21+ _entities . ForEach ( e => e . Links = GetLinkFlags ( e . EntityType ) ) ;
22+
2523 var graph = new ContextGraph ( )
2624 {
2725 Entities = _entities ,
@@ -41,8 +39,7 @@ public void AddResource<TResource>(string pluralizedTypeName) where TResource :
4139 EntityName = pluralizedTypeName ,
4240 EntityType = entityType ,
4341 Attributes = GetAttributes ( entityType ) ,
44- Relationships = GetRelationships ( entityType ) ,
45- Links = GetLinkFlags ( entityType )
42+ Relationships = GetRelationships ( entityType )
4643 } ) ;
4744 }
4845
@@ -112,7 +109,7 @@ public void AddDbContext<T>() where T : DbContext
112109 && dbSetType . GetGenericTypeDefinition ( ) == typeof ( DbSet < > ) )
113110 {
114111 var entityType = dbSetType . GetGenericArguments ( ) [ 0 ] ;
115-
112+
116113 VerifyEntityIsNotAlreadyDefined ( entityType ) ;
117114
118115 _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)
2929
3030 public void BuildContextGraph ( Action < IContextGraphBuilder > builder )
3131 {
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 ;
3433
3534 builder ( ContextGraphBuilder ) ;
3635
Original file line number Diff line number Diff line change @@ -80,11 +80,7 @@ public void Page_Links_Can_Be_Disabled_Globally()
8080 _pageManager . TotalRecords = 1 ;
8181 _pageManager . CurrentPage = 1 ;
8282
83- _options . BuildContextGraph ( builder =>
84- {
85- builder . DocumentLinks = Link . None ;
86- builder . AddResource < Model > ( "models" ) ;
87- } ) ;
83+ _options . BuildContextGraph ( builder => builder . DocumentLinks = Link . None ) ;
8884
8985 _jsonApiContextMock
9086 . Setup ( m => m . ContextGraph )
You can’t perform that action at this time.
0 commit comments