Skip to content

Commit

Permalink
Cast queryNode to SingleResourceCastNode as well
Browse files Browse the repository at this point in the history
  • Loading branch information
WanjohiSammy committed Sep 3, 2024
1 parent 32172ec commit 53d9268
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/Microsoft.AspNetCore.OData/Query/Expressions/QueryBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,17 @@ public virtual Expression BindSingleResourceCastFunctionCall(SingleResourceFunct

IEdmModel model = context.Model;

string targetEdmTypeName = (string)((ConstantNode)node.Parameters.Last()).Value;
string targetEdmTypeName = null;
QueryNode queryNode = node.Parameters.Last();
if (queryNode is ConstantNode constantNode)
{
targetEdmTypeName = constantNode.Value as string;
}
else if (queryNode is SingleResourceCastNode singleResourceCastNode)
{
targetEdmTypeName = singleResourceCastNode.TypeReference.FullName();
}

IEdmType targetEdmType = model.FindType(targetEdmTypeName);
Type targetClrType = null;

Expand Down

0 comments on commit 53d9268

Please sign in to comment.