Skip to content

Commit c73c2ad

Browse files
committed
Merge branch 'master' into merge-v5-into-openapi
2 parents 0e82d2a + 71e5398 commit c73c2ad

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<MicrosoftCodeAnalysisVersion>4.1.*</MicrosoftCodeAnalysisVersion>
88
<HumanizerVersion>2.14.1</HumanizerVersion>
99
<SwashbuckleVersion>6.2.*</SwashbuckleVersion>
10-
<JsonApiDotNetCoreVersionPrefix>5.0.1</JsonApiDotNetCoreVersionPrefix>
10+
<JsonApiDotNetCoreVersionPrefix>5.0.2</JsonApiDotNetCoreVersionPrefix>
1111
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CodingGuidelines.ruleset</CodeAnalysisRuleSet>
1212
<WarningLevel>9999</WarningLevel>
1313
<Nullable>enable</Nullable>

src/JsonApiDotNetCore/Resources/SortExpressionLambdaConverter.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ private static (Expression? innerExpression, bool isCount) TryReadCount(Expressi
116116
{
117117
if (expression is MemberExpression memberExpression)
118118
{
119-
ResourceType resourceType = _resourceGraph.GetResourceType(memberExpression.Member.DeclaringType!);
119+
ResourceType resourceType = memberExpression.Member.Name == nameof(Identifiable<object>.Id) && memberExpression.Expression != null
120+
? _resourceGraph.GetResourceType(memberExpression.Expression.Type)
121+
: _resourceGraph.GetResourceType(memberExpression.Member.DeclaringType!);
122+
120123
AttrAttribute? attribute = resourceType.FindAttributeByPropertyName(memberExpression.Member.Name);
121124

122125
if (attribute != null)

test/JsonApiDotNetCoreTests/IntegrationTests/ResourceInheritance/WheelSortDefinition.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private SortExpression CreateSortFromExpressionSyntax()
4343
{
4444
AttrAttribute paintColorAttribute = ResourceGraph.GetResourceType<ChromeWheel>().GetAttributeByPropertyName(nameof(ChromeWheel.PaintColor));
4545
AttrAttribute hasTubeAttribute = ResourceGraph.GetResourceType<CarbonWheel>().GetAttributeByPropertyName(nameof(CarbonWheel.HasTube));
46+
AttrAttribute idAttribute = ResourceGraph.GetResourceType<Wheel>().GetAttributeByPropertyName(nameof(Wheel.Id));
4647

4748
var cylinderCountChain = new ResourceFieldChainExpression(ImmutableArray.Create<ResourceFieldAttribute>(
4849
ResourceGraph.GetResourceType<Wheel>().GetRelationshipByPropertyName(nameof(Wheel.Vehicle)),
@@ -53,7 +54,8 @@ private SortExpression CreateSortFromExpressionSyntax()
5354
{
5455
new SortElementExpression(new ResourceFieldChainExpression(paintColorAttribute), true),
5556
new SortElementExpression(new ResourceFieldChainExpression(hasTubeAttribute), false),
56-
new SortElementExpression(new CountExpression(cylinderCountChain), true)
57+
new SortElementExpression(new CountExpression(cylinderCountChain), true),
58+
new SortElementExpression(new ResourceFieldChainExpression(idAttribute), true)
5759
}.ToImmutableArray());
5860
}
5961

@@ -63,7 +65,8 @@ private SortExpression CreateSortFromLambdaSyntax()
6365
{
6466
(wheel => (wheel as ChromeWheel)!.PaintColor, ListSortDirection.Ascending),
6567
(wheel => ((CarbonWheel)wheel).HasTube, ListSortDirection.Descending),
66-
(wheel => ((GasolineEngine)((Car)wheel.Vehicle!).Engine).Cylinders.Count, ListSortDirection.Ascending)
68+
(wheel => ((GasolineEngine)((Car)wheel.Vehicle!).Engine).Cylinders.Count, ListSortDirection.Ascending),
69+
(wheel => wheel.Id, ListSortDirection.Ascending)
6770
});
6871
}
6972
}

0 commit comments

Comments
 (0)