Skip to content
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

IQueryable Concat throws "Unable to translate set operation after client projection has been applied" EF Core 8.0.2 #11013

Open
hankrum opened this issue Feb 25, 2025 · 2 comments
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners untriaged New issue has not been triaged by the area owner

Comments

@hankrum
Copy link

hankrum commented Feb 25, 2025

Type of issue

Code doesn't work

Description

`var q1 = _diagnosisDataRepository
.Entities
.Where(ddi => !ddi.DataDefinition.Instances.Any() && ddi.DataDefinition.DataStorageId == id)
.Where(did => did.DiagnosisDefinition.Instances.Any())
.Select((DiagnosisDefinitionIdsDataDefinitionId ddi) => new DataDefinitionCustom
{
DataDefinitionId = ddi.DataDefinition.Id,
Instance = ddi.DiagnosisDefinition.Instances.First(),
});

var q2 = _dataDefinitionRepository
.Entities
.Where(dd => dd.DataStorageId == id && dd.Instances != null && dd.Instances.Any()).AsQueryable()
.Select((DataDefinition dd) => new DataDefinitionCustom
{
DataDefinitionId = dd.Id,
Instance = dd.Instances.First()
});

var q3 = q1.Concat(q2);

var t1 = q1.ToQueryString();
var t2 = q2.ToQueryString();

var q4 = q3.ToArray();`

[Enter feedback here]
This throws an exception

Unable to translate set operation after client projection has been applied. Consider moving the set operation before the last ‘Select’ call…

On the other hand when I get the t1 and t2 sql for the requests and execute then on the database with UNION ALL, everything is fine. So it is some Entity Framework bug. Does anyone have an idea how to avoid it?

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.linq.queryable.concat?view=net-8.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.Linq/Queryable.xml

Document Version Independent Id

e5092ed5-37ad-fd2e-451f-ef49a5225856

Article author

@dotnet-bot

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Feb 25, 2025
@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 25, 2025
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

1 similar comment
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@hankrum hankrum changed the title IQueryable Concat throws "Unable to translate set operation after client projection has been applied" IQueryable Concat throws "Unable to translate set operation after client projection has been applied" EF Core 8.0.2 Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

1 participant