-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Enums as Keys in OData Client #3013
Conversation
…ith struct as generic argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be good to add a test that shows that querying data by keys with enum executes corectly without throwing an exception, just to make sure that the big-picture scenario that is describe in the original issue is resolved.
@habbes Yes, this can be done. However, I have added tests on the specific methods that are called when getting test/FunctionalTests/Microsoft.OData.Client.Tests/Metadata/ClientTypeUtilTests.cs |
@WanjohiSammy Probably add a test(s) to verify that nullable properties are not permitted (other than nullable enum property). Also create an issue to fix it in next major release such that no nullable property area allowed. We published ODL 8 RC so I don't think we can sneak in the change in ODL 8 |
@gathogojr I already added a test for this case where I am using a |
e67b52e
@habbes Thanks for this. I have added these tests in the file test/FunctionalTests/Microsoft.OData.Client.Tests/Tracking/DataServiceContextQueryTests.cs |
test/FunctionalTests/Microsoft.OData.Client.Tests/Tracking/DataServiceContextQueryTests.cs
Outdated
Show resolved
Hide resolved
…ter by composite keys
test/FunctionalTests/Microsoft.OData.Client.Tests/Metadata/ClientTypeUtilTests.cs
Show resolved
Hide resolved
test/FunctionalTests/Microsoft.OData.Client.Tests/Tracking/DataServiceContextQueryTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and follow-up on feedback.
test/FunctionalTests/Microsoft.OData.Client.Tests/Tracking/DataServiceContextQueryTests.cs
Outdated
Show resolved
Hide resolved
* Checkout from 'main' * Add and modify test cases * Only allow nullable Generic Type Enum * Adding a test that throws Exception if key is nullable generic type with struct as generic argument * Adding a test to mock querying data with enum as keys * Add a test to select single entity * Add test to filter by enum member name and a test to use ByKey to filter by composite keys * Add a test to filter by enum key only using ByKey()
…nteger value in squote and without squote (#3018) * Support Enums as Keys in OData Client (#3013) * Checkout from 'main' * Add and modify test cases * Only allow nullable Generic Type Enum * Adding a test that throws Exception if key is nullable generic type with struct as generic argument * Adding a test to mock querying data with enum as keys * Add a test to select single entity * Add test to filter by enum member name and a test to use ByKey to filter by composite keys * Add a test to filter by enum key only using ByKey() * Allow $filtering with enum integer value in squote and without squote (#3014) * Allow comparison with underlying integral for Enum member and add capability to convert integral value to enum member name * Bump with tests * Move helper methods to EnumHelper, use them to check for enum values and adds more tests to handle float, long and int. * Use explicit/exact type instead of 'var' * Add more tests to handle huge, long values * Add assertion for comparing enum member name with the result * Move extension methods from Edm EnumHelper.cs to Core in EdmExtensionMethods.cs
Issues
This pull request fixes #2964.
Description
This change involves adding functionality to support the use of
enumeration types
askeys
.Currently, attempting to query entities with
enums as keys
throughOData Client
, results in an error stating that the operation is not valid for non-generic types.Exception:
This operation is only valid on generic types.
Change:
This modification will address this issue, allowing
enums
as keys without causing exceptions.For example, the below
Employee
object
hasEmpType
which is a key ofType Enum
andNullableEmpType
which isnullable generic Type with Enum as generic argument
.Checklist (Uncheck if it is not completed)
Additional work necessary
If documentation update is needed, please add "Docs Needed" label to the issue and provide details about the required document change in the issue.