Replies: 3 comments 6 replies
-
That's a feature request for EF Core. |
Beta Was this translation helpful? Give feedback.
-
Well, since I own the type, I can just use my own extension method How to generalize the solution? Frankly, not sure either 😄 Allowing users to pass a MethodInfo of their extension method would solve everything, but that would be a weird API and I assume you don't want that. The Clear/Add approach, not sure if that would be correctly interpreted by EF Core (we need expressions here). So, I'm out of ideas. |
Beta Was this translation helpful? Give feedback.
-
Try the MyGet build. |
Beta Was this translation helpful? Give feedback.
-
Please find the full sample app here (it's a single top-level file).
Background
Now that the
record
type is introduced, it's common to utilize it for UI models. It's handy for testing, especially thewith
syntax and the value equality. That said, not rarely do we define custom collection types and use them for inner collections to account for value equality. Let's name itValueList
. Example:Issue
The issue arises during the projection, it's unable to project to these custom collection types. The source of the issue is in EnumerableProjectionMapper since
ToList
/ToArray
extension methods are used to construct the destination inner collection, and that of course fails. Refer to the full sample app here.For now, I'm writing my own
IProjectionMapper
implementation and inserting it toProjectionMappers
(beforeEnumerableProjectionMapper
). But, it would be nice if we have a more robust solution to this.MethodInfo
(this would be weird 😄)Version
AutoMapper Version="11.0.1"
AutoMapper.Extensions.Microsoft.DependencyInjection Version="11.0.0"
Microsoft.EntityFrameworkCore Version="6.0.2"
Microsoft.EntityFrameworkCore.Sqlite Version="6.0.2"
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions