Possible ODataConventionModelBuilder bug when running EntitySet<> on a model with base class parameters hidden by new keyword
@xuzhg is already working on this.
Since Sep 6, 2023.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
consider a base class for WeatherForcast:
public enum CloudType
{
A = 1, B = 2
}
public class WeatherForecastBase
{
public int CloudType { get; set; }
}
public class WeatherForecast : WeatherForecastBase
{
public Guid Id { get; set; }
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
public virtual Person WeatherPerson { get; set; }
public virtual IList<Location> Locations { get; set; }
public virtual Location Location { get; set; }
public Address Address { get; set; }
public bool IsCloudy { get; set; }
public new CloudType CloudType { get; set; }
}
The CloudType (int) property is hidden by the child class with a new property that also changes it's type (CloudType enum). Is there a way for ODataConventionModelBuilder to successfully build a model for WeatherForecast and ignore the base class version of CloudType? In my use case I get an error about the property must be a primative type:
System.ArgumentException: 'The property 'CloudType' on type 'WeatherForecast' must be a Primitive property. (Parameter 'propertyInfo')'
Originally posted by @Jollarvia in https://github.com/OData/AspNetCoreOData/discussions/1043
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.
Assessment
This issue has not been assessed yet.