Skip to content

Commit

Permalink
Ensure that elementType is not null when calling elementType.IsUntyped()
Browse files Browse the repository at this point in the history
  • Loading branch information
CronKz authored and xuzhg committed Feb 29, 2024
1 parent d4aa9a5 commit 6dc9066
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Microsoft.AspNetCore.OData/Query/EnableQueryAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,6 @@ protected virtual ODataQueryOptions CreateQueryOptionsOnExecuting(ActionExecutin
}

IEdmType elementType = edmType.AsElementType();
if (elementType.IsUntyped())
{
// TODO: so far, we don't know how to process query on Edm.Untyped.
// So, if the query data type is Edm.Untyped, or collection of Edm.Untyped,
// Let's simply skip it now.
return null;
}

IEdmModel edmModel = request.GetModel();

// For Swagger metadata request. elementType is null.
Expand All @@ -153,6 +145,14 @@ protected virtual ODataQueryOptions CreateQueryOptionsOnExecuting(ActionExecutin
return null;
}

if (elementType.IsUntyped())
{
// TODO: so far, we don't know how to process query on Edm.Untyped.
// So, if the query data type is Edm.Untyped, or collection of Edm.Untyped,
// Let's simply skip it now.
return null;
}

Type clrType = edmModel.GetClrType(elementType.ToEdmTypeReference(isNullable: false));

// CLRType can be missing if untyped registrations were made.
Expand Down

0 comments on commit 6dc9066

Please sign in to comment.