-
Notifications
You must be signed in to change notification settings - Fork 349
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
Update ODataTypeInfo.cs not correctly identifying entity keys by "Id" property #3050
base: main
Are you sure you want to change the base?
Conversation
I found an issue where the Conventional Id fields are not recognized as key fields. As the Property Name Ends with Id, rather than "ID". The result is that the EdmModel is properly defining the key property, however on the client the EntityType is resolved as "ComplexType" and failures in tracking occur later on in the pipeline.
@microsoft-github-policy-service agree company="Microsoft" |
Fixed casing
Added unit tests for conventional keys
The following test fails in the pipeline:
|
@lawynn The test that fails uses entity types with both key attributes, [Key("CustomerID")]
public class BaseCustomer
{
[OriginalName("CustomerID")]
public string Id { get; set; }
} Here's the test that fails for reference: https://github.com/OData/odata.net/blob/main/test/FunctionalTests/Microsoft.OData.Client.Tests/ALinq/PreserveTypesAndAttributesTests.cs#L137 |
Added check for anonymous types when determining if a property is a key property.
Added IsAnonymousProperty, and IsAnonymousType extensions
@habbes the test is failing is due to the use of an anonymous type in the expression tree. I have added a short circuit in the case where the declaring type is an anonymous type. All tests again pass locally. |
@habbes to clarify further, the bug was always there, and would have manifest had the test classes used differently named key properties. |
I found an issue where the Conventional Id fields are not recognized as key fields. As the Property Name Ends with Id, rather than "ID". The result is that the EdmModel is properly defining the key property, however on the client the EntityType is resolved as "ComplexType" and failures in tracking occur later on in the pipeline.
Issues
#3052
Description
This change finds Id properties using Case Insensitivity for cases where the [Key()] attribute is not defined.
Checklist (Uncheck if it is not completed)