Support type cast with a complex property defined on the derived type in groupby
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 505
- Forks
- 186
- PR merge metrics
- No merged PRs in 30d
Description
Assemblies affected
- Microsoft.AspNetCore.OData 8.x
- Microsoft.AspNetCore.OData 9.x
Describe the bug
Grouping by a nested property of a derived type does not return the expected results. Scenario uncovered here
Reproduce steps
Use the following code for a simple OData service to repro the issue
// Data models
namespace Microsoft.AspNetCore.OData.E2E.Tests.DollarApply
{
public class MyCustomer
{
public int Id { get; set; }
public MyAddress Address { get; set; }
}
public class MyAddress
{
public string Street { get; set; }
}
public class MyHomeAddress : MyAddress
{
public MyCity City { get; set; } // Complex property
}
public class MyCity
{
public string Name { get; set; }
}
}
// Edm model
var builder = new ODataConventionModelBuilder();
builder.EntitySet<MyCustomer>("MyCustomers");
builder.ComplexType<MyAddress>();
builder.ComplexType<MyHomeAddress>();
builder.ComplexType<MyCity>();
var model = builder.GetEdmModel();
// Controller
public class MyCustomersController : ODataController
{
private static readonly List<MyCustomer> myCustomers = new List<MyCustomer>
{
new MyCustomer
{
Id = 1,
Address = new MyHomeAddress { Street = "High Street", City = new MyCity { Name = "Belfast" } }
},
new MyCustomer
{
Id = 2,
Address = new MyHomeAddress { Street = "Moore Street", City = new MyCity { Name = "Dublin" } }
}
};
[EnableQuery]
public ActionResult<IEnumerable<MyCustomer>> Get()
{
return myCustomers;
}
}
Data Model
Shared in the "Reproduce steps" section
EDM (CSDL) Model
Shared in the "Reproduce steps" section
Request/Response
Request:
GET http://localhost/MyCustomers?$apply=groupby((Address/Microsoft.AspNetCore.OData.E2E.Tests.DollarApply.MyHomeAddress/City/Name))
Response:
{"value":[{"Address":{}},{"Address":{}}]}
Expected behavior
The following response should be returned:
{"value":[{"Address":{"City":{"Name":"Belfast"}}},{"Address":{"City":{"Name":"Dublin"}}}]}
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 by running the supplied OData service and the $apply=groupby request against Microsoft.AspNetCore.OData 8.x or 9.x. Trace the handling of the derived-type cast and nested complex property; done means the response includes City.Name with Belfast and Dublin rather than empty Address objects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100