Open aspirio187 opened 1 year ago
Based on the information provided, it appears that the issue is related to the difficulty in retrieving related objects from the API. Currently, only the ID of the related object is returned, which makes it more difficult to work with the data. The proposed solution is to either work like OData API by adding an optional argument in the route to provide the complete object with relation or to keep working with the current solution.
One alternative solution could be to use a data projection technique such as Entity Framework Core's Include method or Select method with anonymous types. These methods allow you to retrieve related objects along with the primary object, without the need for an additional API call. For example:
// Fetch an order and include the related customer
var order = _context.Orders
.Include(o => o.Customer)
.FirstOrDefault(o => o.Id == orderId);
// Fetch an order and project it into an anonymous type with the related customer
var order = _context.Orders
.Where(o => o.Id == orderId)
.Select(o => new
{
Order = o,
Customer = o.Customer
})
.FirstOrDefault();
By using data projection, you can retrieve related objects along with the primary object, without the need for an additional API call. This can improve performance and make it easier to work with the data.
Overall, there are multiple approaches to addressing the difficulty in retrieving related objects from the API. The most appropriate solution will depend on the specific requirements and constraints of the API and the needs of the API consumers.
Is your feature request related to a problem? Please describe.
When retrieving an element from the API, we only get the ID of the related object. It would be easier to directly return the object with the relation
Describe the solution you'd like
Either work like OData API by adding a optional argument in the route providing the complete object or just keep working with the current solution
Describe alternatives you've considered
Changing the API to an OData V4 API
Additional context
...