-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Support MemberMemberBinding #16867
Comments
Do you happen to have an approximate timeline for this feature request? And do you plan to support We are using protobuf-generated C# classes as DTOs and having trouble projecting to repeated fields (i.e., lists) due to context.Users.Select(u => new UserProto {
Roles = {
u.Roles.Select(...),
},
}).ToList(); This doesn't work due to EFCore not supporting |
@erdalsivri We use votes (👍) on issues as a rough measure of customer demand for issues, which then feeds into the planning process. This issue doesn't have any votes, which means there are more than 500 issues ahead of it in the voting. |
I have same issue with you LOL |
Currently, I found the work around solution: I create use partial class with the same name from the generated. public sealed partial class PostResponse
{
public PostResponse(IEnumerable<string> tags): base()
{
Tags.AddRange(tags);
}
} And the projection will look like bellow: x => new PostResponse(x.TagSlugs)
{
Id = x.Id.ToString(),
Title = x.Title,
Slug = x.Slug,
Excerpt = x.Excerpt,
Content = x.Content,
} you can also use the constructor like bellow, but it will cause of getting all columns public PostResponse(IEnumerable<Tag> tags) : base()
{
Tags.AddRange(tags.Select(x => x.Slug));
} |
Running into the same use-case with auto generated gRPC classes |
Using the approach outlined in #16867 (comment), was working fine in EF Core 8, but now throws an exception in EF Core 9 RC var entities= await dbContext.Entities
.AsNoTracking()
.Skip(pageIndex * pageSize)
.Take(pageSize)
.OrderBy(a => a.Prop1)
.Select(a => new Protobuf.Entity(a.Values.Select(v => v.LinkedEntity.Name!))
{
Prop1= a.Prop1,
Prop2 = a.Prop2 ,
})
.ToListAsync(); exception thrown
versions in Directory.Package.props <PackageVersion Include="Microsoft.EntityFrameworkCore" Version="9.0.0-rc.2.24474.1"/>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-rc.2.24474.1"/>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="9.0.0-rc.2.24474.1"/>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0-rc.2.24474.1"/>
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0-rc.2"/> |
Hey @russcam 👋 MemberMemberBinding should indeed be working in the final select (client evaluation), this issue is more about enabling it in other contexts... If EF 9 regressed support for this, that's probably something we should look at - can you please open a separate issue with a minimal repro? |
This tracks adding support for MemberMemberBinding in our query pipeline (first discussed in #16791).
Some preliminary work was done and is available in https://github.com/roji/EntityFrameworkCore/tree/MemberMemberBinding.
The text was updated successfully, but these errors were encountered: