Skip to content

Commit

Permalink
Attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
clemvnt committed May 8, 2024
1 parent bbe2ac7 commit bb6047b
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/Microsoft.OData.Core/UriParser/Aggregation/ApplyBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,30 +230,23 @@ private GroupByTransformationNode BindGroupByToken(GroupByToken token)
foreach (EndPathToken propertyToken in token.Properties)
{
QueryNode bindResult = this.bindMethod(propertyToken);
SingleValuePropertyAccessNode property = bindResult as SingleValuePropertyAccessNode;
SingleComplexNode complexProperty = bindResult as SingleComplexNode;

if (property != null)
if (bindResult is SingleValuePropertyAccessNode property)
{
RegisterProperty(properties, ReversePropertyPath(property));
}
else if (complexProperty != null)
else if (bindResult is SingleComplexNode complexProperty)
{
RegisterProperty(properties, ReversePropertyPath(complexProperty));
}
else if (bindResult is SingleValueOpenPropertyAccessNode openProperty)
{
RegisterProperty(properties, ReversePropertyPath(openProperty));
}
else
{
SingleValueOpenPropertyAccessNode openProperty = bindResult as SingleValueOpenPropertyAccessNode;
if (openProperty != null)
{
IEdmTypeReference type = GetTypeReferenceByPropertyName(openProperty.Name);
properties.Add(new GroupByPropertyNode(openProperty.Name, openProperty, type));
}
else
{
throw new ODataException(
ODataErrorStrings.ApplyBinder_GroupByPropertyNotPropertyAccessValue(propertyToken.Identifier));
}
throw new ODataException(
ODataErrorStrings.ApplyBinder_GroupByPropertyNotPropertyAccessValue(propertyToken.Identifier));
}
}

Expand Down Expand Up @@ -305,6 +298,10 @@ private static Stack<SingleValueNode> ReversePropertyPath(SingleValueNode node)
{
node = ((SingleNavigationNode)node).Source as SingleValueNode;
}
else if (node.Kind == QueryNodeKind.SingleValueOpenPropertyAccess)
{
node = ((SingleValueOpenPropertyAccessNode)node).Source;
}
}
while (node != null && IsPropertyNode(node));

Expand Down Expand Up @@ -350,6 +347,10 @@ private static string GetNodePropertyName(SingleValueNode property)
{
return ((SingleNavigationNode)property).NavigationProperty.Name;
}
else if (property.Kind == QueryNodeKind.SingleValueOpenPropertyAccess)
{
return ((SingleValueOpenPropertyAccessNode)property).Name;
}
else
{
throw new NotSupportedException();
Expand Down

0 comments on commit bb6047b

Please sign in to comment.