AutoMapper / AutoMapper.Extensions.OData

Creates LINQ expressions from ODataQueryOptions and executes the query.
MIT License
140 stars 38 forks source link

Inherited DTO properties appear to be ignored #132

Closed BlaiseD closed 2 years ago

BlaiseD commented 2 years ago

Discussed in https://github.com/AutoMapper/AutoMapper.Extensions.OData/discussions/131

Originally posted by **Kizzik** April 13, 2022 I have a series of DTOs with common properties (Id, CreatedOn, CreatedBy) etc that I have split out as a BaseDto. A primitive example: `public class BaseDto { public Guid Id { get; set; } }` `public class SampleDto : BaseDto { public string Name { get; set; } = null!; }` When I retrieve my SampleDtos, the back-end query being generated by EntityFramework looks like this (note that Id isn't included): `SELECT [s].[Name] FROM [Samples] AS [s]` If, however, I have my entity's properties all directly within the DTO, it works as expected: `public class SampleDto { public Guid Id { get; set; } public string Name { get; set; } = null!; }` Will generate: `SELECT [s].[Id], [s].[Name] FROM [Samples] AS [s]` Have I discovered an issue/limitation, or am I doing something wrong?