Hello, I'm currently devloping a .NETCore application. The application is divided into three layers: Data Layer(with models definition), Service Layer (to retrieve data and return it as IQueryable objects) and the Application Layer (where Telerik is installed).
My controller read action in the ApplicationLayer is as follows:
public IActionResult ReadAziende([FromServices] IAziendaService service, [DataSourceRequest] DataSourceRequest request)
var aziende = service.ListWithIncludes().ToDataSourceResult(request, m => _mapper.Map<IndiceAziendaVM>(m));
The Service Layer action ListWithIncludes is as follows:
public IQueryable<AziendaFullIncludeDTO> ListWithIncludes()
.Include(a => a.Settore)
.Include(a => a.Indirizzi)
.Include(a => a.Tags)
.ThenInclude(a => a.Tag)
.Include(a => a.CodiceAteco)
.Include(a => a.TenantDataAccess)
.ThenInclude(a => a.Tenant)
.Select(a => _mapper.Map<AziendaFullIncludeDTO>(a)) ;
The Service Layer is correctly returning the DTO with included fields in an IQueryable Object but as soon as I pass it to ToDataSourceResult all included fields get lost.
What is the correct way to apply ToDataSourceResult to an IQueryable Object with Included navigation properties?