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

select new {} in a selectmany fails #11219

Closed
yepeekai opened this issue Mar 9, 2018 · 1 comment
Closed

select new {} in a selectmany fails #11219

yepeekai opened this issue Mar 9, 2018 · 1 comment
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. regression type-bug
Milestone

Comments

@yepeekai
Copy link

yepeekai commented Mar 9, 2018

query.SelectMany(e => e.EntitiesB.Select(b => b.Something)).Take(1).ToList(); //works
query.SelectMany(e => e.EntitiesB.Select(b => new { b.Something})).Take(1).ToList(); //fails

Exception:

System.ArgumentException: 'System.Linq.IQueryable`1[<>f__AnonymousType52`1[System.Int32]]' cannot be used as the data type for a sequence with an ItemExpression of type 'entityb'.
Parameter name: dataType
   at Remotion.Linq.Clauses.StreamedData.StreamedSequenceInfo.AdjustDataType(Type dataType)
   at Remotion.Linq.QueryModel.GetOutputDataInfo()

Remotion.Linq.QueryModel.GetOutputDataInfo()
Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.TrackResults(QueryModel queryModel)
Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, bool asyncQuery)
Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.OptimizeQueryModel(QueryModel queryModel, bool asyncQuery)
Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor<TResult>(QueryModel queryModel)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore<TResult>(Expression query, IQueryModelGenerator queryModelGenerator, IDatabase database, IDiagnosticsLogger<Query> logger, Type contextType)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler+<>c__DisplayClass13_0.<Execute>b__0()
Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore<TFunc>(object cacheKey, Func<Func<QueryContext, TFunc>> compiler)
Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute<TResult>(Expression query)
Remotion.Linq.QueryableBase.GetEnumerator()
System.Collections.Generic.List..ctor(IEnumerable<T> collection)
System.Linq.Enumerable.ToList<TSource>(IEnumerable<TSource> source)
@ajcvickers ajcvickers added this to the 2.1.0 milestone Mar 14, 2018
maumar added a commit that referenced this issue Mar 21, 2018
Problem was that we were trying to convert SelectMany on a subquery with a non-qsre projection into join. We should only do that for subqueries with qsre selectors, because otherwise type of generated join qsre would not match the original type.
@maumar
Copy link
Contributor

maumar commented Mar 21, 2018

fixed in 30809ca

@maumar maumar closed this as completed Mar 21, 2018
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 21, 2018
@ajcvickers ajcvickers modified the milestones: 2.1.0-preview2, 2.1.0 Nov 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. regression type-bug
Projects
None yet
Development

No branches or pull requests

3 participants