I am not sure why I am getting the error: "Must be reducible node"
This is my query. I am running Core 2 with EF Core 2.2 (So I should have the fixes that occurred in previous versions)
IQueryable<Gizmo> gizmos = _context.Gizmo;
IQueryable<GizmoViewModel> dataReferences = (
gizmos.SelectMany(j => j.DataReferences.Select(r =>
new GizmoViewModel()
{
GizmoId = j.Id,
DataId = r.DataId
}
))
);
Simply (and sadly) you are hitting one of the current EF Core query translation bugs.
Looks like it's caused by the accessing the outer SelectMany
lambda parameter inside the inner Select
expression.
The workaround is to use another SelectMany
overload having a second lambda with both outer and inner parameters (which I guess is used by C# compiler when converting LINQ query syntax):
IQueryable<GizmoViewModel> dataReferences = (
gizmos.SelectMany(j => j.DataReferences, (j, r) =>
new GizmoViewModel()
{
GizmoId = j.Id,
DataId = r.DataId
}
)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With