Repository navigation
Can I do an IQueryable projection from a string[] column in postgres to a protobuf message? #1840
|
Feature intro: https://mapperly.riok.app/docs/configuration/queryable-projections/ public class BaseSomething
{
public BaseSomething(
string[] someTypes)
{
SomeTypes = someTypes;
}
public string[] SomeTypes { get; set; }
}
public static partial IQueryable<BaseSomethingMessage> ProjectToDto(this IQueryable<BaseSomething> q);message BaseSomethingMessage {
repeated string SomeTypes = 1;
}The generated MESSAGE C# class has the following types: MyProject.csproj <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.31.0"/>
<PackageReference Include="Grpc.AspNetCore" Version="2.71.0"/>
<PackageReference Include="Grpc.Tools" Version="2.72.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<Protobuf Include="Proto\BaseSomethingMessage.proto">
<Access>Public</Access>
<AdditionalImportDirs>.\Protos</AdditionalImportDirs>
<GrpcServices>Both</GrpcServices>
<ProtoCompile>True</ProtoCompile>
<CompileOutputs>True</CompileOutputs>
<OutputDir>obj\Debug\net9.0\</OutputDir>
<Generator>MSBuild:Compile</Generator>
</Protobuf>
</ItemGroup>I tried this mapping, but it didn't auto-generate correctly, and I tried the following manually, which was not possible. /// Cannot be created correctly.
public static partial IQueryable<BaseSomethingMessage> ProjectToDto(this IQueryable<BaseSomething> q)/// System.InvalidOperationException: EF Core does not support MemberListBinding: 'new Blog { Posts = { new Post(), new Post() } }'.
/// at Microsoft.EntityFrameworkCore.Query.Internal.ExpressionTreeFuncletizer.VisitMemberListBinding(MemberListBinding node)
public static IQueryable<BaseSomethingMessage> ProjectToDto(this IQueryable<BaseSomething> q)
{
#nullable disable
return global::System.Linq.Queryable.Select(
q,
x => new global::SomeMessagesProto.Generated.BaseSomethingMessage()
{
SomeTypes = { x.SomeTypes },
}
);
#nullable enable
}/// Cannot convert source type 'string[]' to target type 'Google.Protobuf.Collections.RepeatedField<string>'
BusinessTypes = x.BusinessTypes,If there is no way, should I raise an issue? Or has it already been reviewed and deemed difficult? |
Answered by
latonz
May 22, 2025
Replies: 2 comments 3 replies
|
I don‘t think EF core supports projecting to a protobuf repeated field. Does it work if you write the select manually instead of using Mapperly? If so, could you provide the code? |
3 replies
Model ladder update — explicit checkpoints pinnedPer @keunwoo-ortet's K5 clarification request, here is the explicit model ladder with pinned checkpoints for #9798. All entries are post-trained (instruct/chat) variants unless noted otherwise. 1. Smoke test — small, fast iteration
2. Small MoE — framework stress at moderate scale
3. RL target candidate — large MoE
4. Alternative / comparison candidate
Notes
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If your custom written code doesn‘t work, unfortunately there is no way for Mapperly to handle this case.