@@ -131,21 +131,21 @@ private IncludeExpression ComposeChildren(QueryLayer topLayer, ICollection<Expre
131
131
// @formatter:keep_existing_linebreaks restore
132
132
// @formatter:wrap_chained_method_calls restore
133
133
134
- IImmutableList < IncludeElementExpression > includeElements =
134
+ IImmutableSet < IncludeElementExpression > includeElements =
135
135
ProcessIncludeSet ( include . Elements , topLayer , new List < RelationshipAttribute > ( ) , constraints ) ;
136
136
137
137
return ! ReferenceEquals ( includeElements , include . Elements )
138
138
? includeElements . Any ( ) ? new IncludeExpression ( includeElements ) : IncludeExpression . Empty
139
139
: include ;
140
140
}
141
141
142
- private IImmutableList < IncludeElementExpression > ProcessIncludeSet ( IImmutableList < IncludeElementExpression > includeElements , QueryLayer parentLayer ,
142
+ private IImmutableSet < IncludeElementExpression > ProcessIncludeSet ( IImmutableSet < IncludeElementExpression > includeElements , QueryLayer parentLayer ,
143
143
ICollection < RelationshipAttribute > parentRelationshipChain , ICollection < ExpressionInScope > constraints )
144
144
{
145
- IImmutableList < IncludeElementExpression > includeElementsEvaluated =
146
- GetIncludeElements ( includeElements , parentLayer . ResourceContext ) ?? ImmutableArray < IncludeElementExpression > . Empty ;
145
+ IImmutableSet < IncludeElementExpression > includeElementsEvaluated =
146
+ GetIncludeElements ( includeElements , parentLayer . ResourceContext ) ?? ImmutableHashSet < IncludeElementExpression > . Empty ;
147
147
148
- var updatesInChildren = new Dictionary < IncludeElementExpression , IImmutableList < IncludeElementExpression > > ( ) ;
148
+ var updatesInChildren = new Dictionary < IncludeElementExpression , IImmutableSet < IncludeElementExpression > > ( ) ;
149
149
150
150
foreach ( IncludeElementExpression includeElement in includeElementsEvaluated )
151
151
{
@@ -187,7 +187,7 @@ private IImmutableList<IncludeElementExpression> ProcessIncludeSet(IImmutableLis
187
187
188
188
if ( includeElement . Children . Any ( ) )
189
189
{
190
- IImmutableList < IncludeElementExpression > updatedChildren =
190
+ IImmutableSet < IncludeElementExpression > updatedChildren =
191
191
ProcessIncludeSet ( includeElement . Children , child , relationshipChain , constraints ) ;
192
192
193
193
if ( ! ReferenceEquals ( includeElement . Children , updatedChildren ) )
@@ -201,16 +201,16 @@ private IImmutableList<IncludeElementExpression> ProcessIncludeSet(IImmutableLis
201
201
return ! updatesInChildren . Any ( ) ? includeElementsEvaluated : ApplyIncludeElementUpdates ( includeElementsEvaluated , updatesInChildren ) ;
202
202
}
203
203
204
- private static IImmutableList < IncludeElementExpression > ApplyIncludeElementUpdates ( IImmutableList < IncludeElementExpression > includeElements ,
205
- IDictionary < IncludeElementExpression , IImmutableList < IncludeElementExpression > > updatesInChildren )
204
+ private static IImmutableSet < IncludeElementExpression > ApplyIncludeElementUpdates ( IImmutableSet < IncludeElementExpression > includeElements ,
205
+ IDictionary < IncludeElementExpression , IImmutableSet < IncludeElementExpression > > updatesInChildren )
206
206
{
207
- ImmutableArray < IncludeElementExpression > . Builder newElementsBuilder = ImmutableArray . CreateBuilder < IncludeElementExpression > ( includeElements . Count ) ;
207
+ ImmutableHashSet < IncludeElementExpression > . Builder newElementsBuilder = ImmutableHashSet . CreateBuilder < IncludeElementExpression > ( ) ;
208
208
newElementsBuilder . AddRange ( includeElements ) ;
209
209
210
- foreach ( ( IncludeElementExpression existingElement , IImmutableList < IncludeElementExpression > updatedChildren ) in updatesInChildren )
210
+ foreach ( ( IncludeElementExpression existingElement , IImmutableSet < IncludeElementExpression > updatedChildren ) in updatesInChildren )
211
211
{
212
- int existingIndex = newElementsBuilder . IndexOf ( existingElement ) ;
213
- newElementsBuilder [ existingIndex ] = new IncludeElementExpression ( existingElement . Relationship , updatedChildren ) ;
212
+ newElementsBuilder . Remove ( existingElement ) ;
213
+ newElementsBuilder . Add ( new IncludeElementExpression ( existingElement . Relationship , updatedChildren ) ) ;
214
214
}
215
215
216
216
return newElementsBuilder . ToImmutable ( ) ;
@@ -301,7 +301,7 @@ private IncludeExpression RewriteIncludeForSecondaryEndpoint(IncludeExpression r
301
301
? new IncludeElementExpression ( secondaryRelationship , relativeInclude . Elements )
302
302
: new IncludeElementExpression ( secondaryRelationship ) ;
303
303
304
- return new IncludeExpression ( ImmutableArray . Create ( parentElement ) ) ;
304
+ return new IncludeExpression ( ImmutableHashSet . Create ( parentElement ) ) ;
305
305
}
306
306
307
307
private FilterExpression CreateFilterByIds < TId > ( IReadOnlyCollection < TId > ids , AttrAttribute idAttribute , FilterExpression existingFilter )
@@ -329,8 +329,8 @@ public QueryLayer ComposeForUpdate<TId>(TId id, ResourceContext primaryResource)
329
329
{
330
330
ArgumentGuard . NotNull ( primaryResource , nameof ( primaryResource ) ) ;
331
331
332
- ImmutableArray < IncludeElementExpression > includeElements = _targetedFields . Relationships
333
- . Select ( relationship => new IncludeElementExpression ( relationship ) ) . ToImmutableArray ( ) ;
332
+ IImmutableSet < IncludeElementExpression > includeElements = _targetedFields . Relationships
333
+ . Select ( relationship => new IncludeElementExpression ( relationship ) ) . ToImmutableHashSet ( ) ;
334
334
335
335
AttrAttribute primaryIdAttribute = GetIdAttribute ( primaryResource ) ;
336
336
@@ -405,7 +405,7 @@ public QueryLayer ComposeForHasMany<TId>(HasManyAttribute hasManyRelationship, T
405
405
406
406
return new QueryLayer ( leftResourceContext )
407
407
{
408
- Include = new IncludeExpression ( ImmutableArray . Create ( new IncludeElementExpression ( hasManyRelationship ) ) ) ,
408
+ Include = new IncludeExpression ( ImmutableHashSet . Create ( new IncludeElementExpression ( hasManyRelationship ) ) ) ,
409
409
Filter = leftFilter ,
410
410
Projection = new Dictionary < ResourceFieldAttribute , QueryLayer >
411
411
{
@@ -422,7 +422,7 @@ public QueryLayer ComposeForHasMany<TId>(HasManyAttribute hasManyRelationship, T
422
422
} ;
423
423
}
424
424
425
- protected virtual IImmutableList < IncludeElementExpression > GetIncludeElements ( IImmutableList < IncludeElementExpression > includeElements ,
425
+ protected virtual IImmutableSet < IncludeElementExpression > GetIncludeElements ( IImmutableSet < IncludeElementExpression > includeElements ,
426
426
ResourceContext resourceContext )
427
427
{
428
428
ArgumentGuard . NotNull ( resourceContext , nameof ( resourceContext ) ) ;
0 commit comments