-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Cannot use [MapDerivedType] with Map(IQueryable) #409
Comments
Thank you for the bug report 😊 |
You have to use the ternary operator and Select(object => object is Child ? new ChildDto() : object is OtherChild ? new OtherChildDto() : default ) note: needs to use more generic projection than |
Hmm how would " is " translate to SQL (or anything else)? This case the user would likely have to manually write an |
@onionhammer It works - EF core will select the required columns and then do the "is" calculation client side. It may lead to over fetching, and maybe left joins (which might be avoided using subqueries with EF7) |
This should now be fixed on main. |
That's amazing. Thank you 🙏 |
Describe the bug
When using [MapDerivedType] and Map(IQuerable) in the same class, the generated code includes a switch statement in the Queryable.Select lambda
To Reproduce
Steps to reproduce the behavior:
Parent
andChild
ParentDto
andChildDto
[MapDerivedType<Child, ChildDto>] public static partial ParentDto ToDto(Parent model);
public partial static IQueryable<ParentDto> ProjectToDto(this IQueryable<Parent> query);
Expected behavior
The generated code should compile, and ideally map the hierachy correctly
Code snippets
Environment (please complete the following information):
Additional context
I know this is pre-release, and I'm not using it in production, but it would be a nice use-case to be fulfilled.
The text was updated successfully, but these errors were encountered: