Skip to content
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

[T4] OData v4 Client Code Generator generates a C# proxy class that won’t compile if the model contains an Entity that has a property with name "Context" #242

Closed
LaylaLiu opened this issue Jul 27, 2015 · 3 comments · Fixed by #333
Labels
backlog bug Something isn't working

Comments

@LaylaLiu
Copy link
Contributor

BaseEntityType contains a property named "Context".

So when a model contains an entity which has a property named "Context". The client generated code will be like

public partial class Product : global::Microsoft.OData.Client.BaseEntityType
{
...
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.OData.Client.Design.T4", "2.1.0")]
[global::Microsoft.OData.Client.OriginalNameAttribute("Context")]
public global::System.Collections.ObjectModel.ObservableCollectionglobal::OutlookApiBetaModel.CustomProperty Context
{
get { ... }
set { ... }
}

This will lead to "ConsoleApplication7.Product.Context' hides inherited member 'Microsoft.OData.Client.BaseEntityType.Context'. Use the new keyword if hiding was intended. “

@LaylaLiu LaylaLiu added the bug Something isn't working label Oct 26, 2015
@AlanWong-MS AlanWong-MS added the P4 label Jun 7, 2017
@mikepizzo
Copy link
Member

Closing due to lack of customer activity. Will re-visit based on any user feedback.

@robertmclaws
Copy link

This issue can be solved by removing the internal "Context" property on BaseEntityType, as it is not presently being used. Separation of Concerns says that the Entity should need to know about the Context it came from anyways.

@habbes habbes transferred this issue from OData/odata.net Feb 1, 2022
@mikepizzo
Copy link
Member

We probably should have named these internal properties such that they had a lower chance of conflicting with user properties. i.e., "__context" or some such.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants