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

Query: Set Operations throw ArgumentNullException when second source is DbSet #7279

Closed
azabluda opened this issue Dec 20, 2016 · 0 comments
Closed
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@azabluda
Copy link

azabluda commented Dec 20, 2016

Simple LINQ query with Concat throws ArgumentNullException

Exception message:
System.ArgumentNullException
Value cannot be null.
Parameter name: querySource

Stack trace:
   at Microsoft.EntityFrameworkCore.Utilities.Check.NotNull[T](T value, String parameterName) in D:\EntityFramework\src\Shared\Check.cs:line 27
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.AddQuery(IQuerySource querySource, SelectExpression selectExpression) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational\Query\RelationalQueryModelVisitor.cs:line 258
   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.RelationalEntityQueryableExpressionVisitor.VisitEntityQueryable(Type elementType) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational\Query\ExpressionVisitors\RelationalEntityQueryableExpressionVisitor.cs:line 159
   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.EntityQueryableExpressionVisitor.VisitConstant(ConstantExpression constantExpression) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\ExpressionVisitors\EntityQueryableExpressionVisitor.cs:line 35
   at Microsoft.EntityFrameworkCore.Query.ExpressionVisitors.ExpressionVisitorBase.Visit(Expression node) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\ExpressionVisitors\ExpressionVisitorBase.cs:line 26
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.ReplaceClauseReferences(Expression expression, IQuerySource querySource, Boolean inProjection) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\EntityQueryModelVisitor.cs:line 1218
   at Microsoft.EntityFrameworkCore.Query.ResultOperatorHandler.HandleSetOperation(EntityQueryModelVisitor entityQueryModelVisitor, Expression secondSource, MethodInfo setMethodInfo) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\ResultOperatorHandler.cs:line 328
   at Microsoft.EntityFrameworkCore.Query.ResultOperatorHandler.HandleConcat(EntityQueryModelVisitor entityQueryModelVisitor, ConcatResultOperator concatResultOperator) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\ResultOperatorHandler.cs:line 133
   at Microsoft.EntityFrameworkCore.Query.ResultOperatorHandler.<>c.<.cctor>b__30_4(EntityQueryModelVisitor v, ResultOperatorBase r, QueryModel __) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\ResultOperatorHandler.cs:line 33
   at Microsoft.EntityFrameworkCore.Query.ResultOperatorHandler.HandleResultOperator(EntityQueryModelVisitor entityQueryModelVisitor, ResultOperatorBase resultOperator, QueryModel queryModel) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\ResultOperatorHandler.cs:line 78
   at Microsoft.EntityFrameworkCore.Query.Internal.RelationalResultOperatorHandler.HandlerContext.EvalOnClient(Boolean requiresClientResultOperator) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational\Query\Internal\RelationalResultOperatorHandler.cs:line 71
   at Microsoft.EntityFrameworkCore.Query.Internal.RelationalResultOperatorHandler.HandleResultOperator(EntityQueryModelVisitor entityQueryModelVisitor, ResultOperatorBase resultOperator, QueryModel queryModel) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational\Query\Internal\RelationalResultOperatorHandler.cs:line 168
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, Int32 index) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\EntityQueryModelVisitor.cs:line 1077
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, Int32 index) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational\Query\RelationalQueryModelVisitor.cs:line 1187
   at Remotion.Linq.QueryModelVisitorBase.VisitResultOperators(ObservableCollection`1 resultOperators, QueryModel queryModel)
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.VisitQueryModel(QueryModel queryModel) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\EntityQueryModelVisitor.cs:line 721
   at Microsoft.EntityFrameworkCore.Query.RelationalQueryModelVisitor.VisitQueryModel(QueryModel queryModel) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.Relational\Query\RelationalQueryModelVisitor.cs:line 373
   at Microsoft.EntityFrameworkCore.Query.Internal.SqlServerQueryModelVisitor.VisitQueryModel(QueryModel queryModel) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.SqlServer\Query\Internal\SqlServerQueryModelVisitor.cs:line 92
   at Microsoft.EntityFrameworkCore.Query.EntityQueryModelVisitor.CreateQueryExecutor[TResult](QueryModel queryModel) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\EntityQueryModelVisitor.cs:line 259
   at Microsoft.EntityFrameworkCore.Storage.Database.CompileQuery[TResult](QueryModel queryModel) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Storage\Database.cs:line 67
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQueryCore[TResult](Expression query, INodeTypeProvider nodeTypeProvider, IDatabase database, ILogger logger, Type contextType) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\Internal\QueryCompiler.cs:line 218
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass19_0`1.<CompileQuery>b__0() in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\Internal\QueryCompiler.cs:line 171
   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func`1 compiler) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\Internal\CompiledQueryCache.cs:line 68
   at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQuery[TResult](Object cacheKey, Func`1 compiler) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\Internal\CompiledQueryCache.cs:line 45
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.CompileQuery[TResult](Expression query) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\Internal\QueryCompiler.cs:line 169
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\Internal\QueryCompiler.cs:line 99
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression) in D:\EntityFramework\src\Microsoft.EntityFrameworkCore\Query\Internal\EntityQueryProvider.cs:line 57
   at Remotion.Linq.QueryableBase`1.GetEnumerator()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Microsoft.EntityFrameworkCore.Specification.Tests.QueryTestBase`1.Concat_simple() in D:\EntityFramework\src\Microsoft.EntityFrameworkCore.Specification.Tests\QueryTestBase.cs:line 5941

Steps to reproduce

Remove Where conditions from the existing test Microsoft.EntityFrameworkCore.Specification.Tests.QueryTestBase<TFixture>.Concat_simple and run it against SqlServer or InMemory database

        [ConditionalFact]
        public virtual void Concat_simple()
        {
            using (var context = CreateContext())
            {
                var query1 = context.Set<Customer>()
                    ;//.Where(c => c.City == "México D.F.");

                var query2 = context.Set<Customer>()
                    ;//.Where(s => s.ContactTitle == "Owner");

                var query3 = query1.Concat(query2).ToList(); // <<< ArgumentNullException

                Assert.Equal(182, query3.Count);
            }
        }

Further technical details

EF Core version: 1.1.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.InMemory
Operating system: Windows 7 Professional SP1
IDE: Visual Studio 2015

@divega divega added the type-bug label Jan 6, 2017
@divega divega added this to the 2.0.0 milestone Jan 6, 2017
@smitpatel smitpatel changed the title Concat throws ArgumentNullException in simplest case Set Operations throw ArgumentNullException when second source is dbset Apr 3, 2017
@smitpatel smitpatel added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 3, 2017
@ajcvickers ajcvickers changed the title Set Operations throw ArgumentNullException when second source is dbset Query: Set Operations throw ArgumentNullException when second source is DbSet May 9, 2017
@divega divega added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels May 10, 2017
@ajcvickers ajcvickers modified the milestones: 2.0.0-preview1, 2.0.0 Oct 15, 2022
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. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants