Enum values case sensitivity
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Is there a way to allow case insensitivity for enum values?
For instance: /odata/v1/apps?$expand=scores($filter=type in ('overall','Basic'))
When ScoreType is defined as:
public enum ScoreType
{
Overall = 0,
Basic = 1,
}
I get an error here, but from what I could see, I'd have to override the FilterBinder which is not a very friendly task.
Any suggestions?
System.ArgumentException: Requested value 'overall' was not found.
at System.Enum.TryParseByName(RuntimeType enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, UInt64& result)
at System.Enum.TryParseInt32Enum(RuntimeType enumType, ReadOnlySpan`1 value, Int32 minInclusive, Int32 maxInclusive, Boolean ignoreCase, Boolean throwOnFailure, TypeCode type, Int32& result)
at System.Enum.TryParse(Type enumType, ReadOnlySpan`1 value, Boolean ignoreCase, Boolean throwOnFailure, Object& result)
at System.Enum.Parse(Type enumType, String value)
at Microsoft.AspNetCore.OData.Query.Expressions.QueryBinder.RetrieveClrTypeForConstant(IEdmTypeReference edmTypeReference, QueryBinderContext context, Object& value)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with QueryBinder.RetrieveClrTypeForConstant, where the stack trace shows enum constants are parsed, and reproduce the provided $filter query using lowercase and mixed-case values. Trace how enum literals are converted during OData query binding. Done means case-insensitive enum values work without the current ArgumentException, with coverage for the shown query patterns.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100