Skip to content

Constructor injection for complex types #31621

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

Open
Tracked by #31238
ajcvickers opened this issue Sep 4, 2023 · 5 comments
Open
Tracked by #31238

Constructor injection for complex types #31621

ajcvickers opened this issue Sep 4, 2023 · 5 comments

Comments

@ajcvickers
Copy link
Contributor

That is, bind an instance of a nested complex type to a constructor parameter.

Related to #12078

@el-genius

This comment has been minimized.

@roji

This comment has been minimized.

@bbartels
Copy link

bbartels commented Apr 1, 2025

Out of curiosity, would this be a reasonable ticket to pick up for a community contribution? Am I correct in assuming that this wouldn't really be touching query pipeline logic? Would be interesting in giving this a shot if not deemed complex enough to only be done by more seasoned EF contributors.
Not had too deep of a look yet, but presumably most of the changes would be happening here?

private bool TryBindConstructor<T>(

@roji
Copy link
Member

roji commented Apr 1, 2025

/cc @AndriySvyryd. Also given we're doing a big push on complex types and given the number of votes, we may want to try to get this in for 10.

@AndriySvyryd
Copy link
Member

I'm not very familiar with this code, but you would also need to modify https://github.com/dotnet/efcore/blob/main/src/EFCore/Metadata/Internal/PropertyParameterBindingFactory.cs and https://github.com/dotnet/efcore/blob/main/src/EFCore/Query/Internal/EntityMaterializerSource.cs#L77

It would be significantly more complex to enable this for collections of complex types or complex properties mapped to JSON, so perhaps it's best to tackle those separately.

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

No branches or pull requests

6 participants