Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetPagedListAsync with mapping in selector and includes don't work #121

Open
eoehen opened this issue Nov 25, 2019 · 1 comment
Open

GetPagedListAsync with mapping in selector and includes don't work #121

eoehen opened this issue Nov 25, 2019 · 1 comment

Comments

@eoehen
Copy link

eoehen commented Nov 25, 2019

var result2 = await unitOfWork.GetRepository<Entity>()
                .GetPagedListAsync(
                    mapping => mapper.Map<EntityDto>(mapping),
                    null,
                    mapping => mapping.OrderBy(map => map.Name),
                    include: source => source.Include(mapping => mapping.Template),
                    queryParameters.PageIndex, queryParameters.PageSize);

The combination of mapping => mapper.Map<EntityDto>(mapping) and an include statement include: source => source.Include(mapping => mapping.Template) dosn't work.

The same stuff in several steps is working well.
f.e. first load without Automapper mapping and second map the entity into the EntityDto after loading pagedList.

This example works correct.

var result = await unitOfWork.GetRepository<Entity>()
                .GetPagedListAsync(
                    mapping => mapping,
                    null,
                    mapping => mapping.OrderBy(map => map.Name), 
                    include: source => source.Include(mapping => mapping.Template),
                    queryParameters.PageIndex, queryParameters.PageSize);

var dtoItems = mapper.Map<List<EntityDto>>(result.Items);

Analyse:

  • Dataloading with include himself is working correct.
  • Automapping himself ist working correct.

But the combination of Dataloading and Automapping in the selection dosn't work.

@eoehen
Copy link
Author

eoehen commented Nov 25, 2019

FYI: GetFirstOrDefaultAsync is working.

var mappingDto = await unitOfWork.GetRepository<Entity>()
	.GetFirstOrDefaultAsync(
		mapping => mapper.Map<EntityDto>(mapping),
		mapping => mapping.Id == id, 
		include: source => source.Include(mapping => mapping.Template));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant