Skip to content

Conversation

kvpt
Copy link

@kvpt kvpt commented Jun 14, 2023

When mapping a polymorphic list with an abstract parent, the expression throw an exception on create.
It try to use a new expression of the abstract type which is not possible.
So replace it with a default value expression which is allowed and not throw an error.

{
var instanceParameter = Parameter(request.SourceType, "dto" + request.SourceType.Name);
var projection = CreateProjectionCore(request, instanceParameter, typeMap, letPropertyMaps);
var projection = !typeMap.DestinationType.IsAbstract
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A better fix is to simply skip abstract types when computing polymorphic maps.

Copy link
Author

@kvpt kvpt Jun 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with that, or perhaps I don't see how to do it this way at this level.
Because the abstract type mapping don't come from the polymorphic map but from the EnumerableProjectionMapper.Project method.
This is because it is this abstract type that is used for the collection property in the entity.
I don't see how I can filter it before this moment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess both make sense, projecting to an abstract type when there are included maps and also including an abstract map, presumably for configuration reuse.

@lbargaoanu lbargaoanu merged commit dab92b1 into LuckyPennySoftware:basic_include Jun 16, 2023
@github-actions
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants