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

GetItemLinqQueryable throwing "Value cannot be null. Parameter name: sqlQuerySpec" #555

Closed
coffeymatt opened this issue Jul 16, 2019 · 2 comments · Fixed by #561
Closed
Assignees
Labels
bug Something isn't working LINQ needs-investigation

Comments

@coffeymatt
Copy link

Describe the bug

I've been migrating from v2 to v3 and a linq query operation I could do before now throws an exception. In this case I'm just getting a bunch of objects of the same type from the same partition. The error I get is:

Value cannot be null.
Parameter name: sqlQuerySpec

To Reproduce

Rough example code:

var partition = "example";
var options = new QueryRequestOptions
{
         PartitionKey = new PartitionKey(partition)
};

var query = this.container.GetItemLinqQueryable<ExampleObject>(true, options).AsQueryable();

var allObjects = query.ToList();

Expected behavior
The above should give me all objects of type 'ExampleObject' in the specified partition, like a query without a where clause. The same linq query was working in V2 of the API.

Actual behavior

Throws exception:

Value cannot be null.
Parameter name: sqlQuerySpec

Environment summary
SDK Version: 3.0.0
OS Version: Windows

Additional context
Add any other context about the problem here (for example, complete stack traces or logs).

Stack trace:

at Microsoft.Azure.Cosmos.Query.CosmosQueryExecutionContextFactory..ctor(CosmosQueryClient client, ResourceType resourceTypeEnum, OperationType operationType, Type resourceType, SqlQuerySpec sqlQuerySpec, String continuationToken, QueryRequestOptions queryRequestOptions, Uri resourceLink, Boolean isContinuationExpected, Boolean allowNonValueAggregateQuery, Guid correlatedActivityId)
at Microsoft.Azure.Cosmos.Linq.CosmosLinqQuery1.CreateCosmosQueryExecutionContext() at Microsoft.Azure.Cosmos.Linq.CosmosLinqQuery1.GetEnumerator()+MoveNext()
at System.Collections.Generic.List1.AddEnumerable(IEnumerable1 enumerable)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Cosmos.Domain.Feature.DeviceManagementFeature.Services.DeviceService.GetEnrollments() in C:\Users\PaulMatthew\Source\Repos\Cosmos\Cosmos.Domain\Feature\DeviceManagementFeature\Services\DeviceService.cs:line 222
at Cosmos.WebPortal.Controllers.DeviceManagerController.GetEnrollments() in C:\Users\PaulMatthew\Source\Repos\Cosmos\Cosmos.WebPortal\Controllers\DeviceManagerController.cs:line 76
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()

@j82w j82w added bug Something isn't working LINQ needs-investigation labels Jul 16, 2019
@j82w j82w self-assigned this Jul 16, 2019
@j82w
Copy link
Contributor

j82w commented Jul 16, 2019

This is a bug. I have a repo and working on a fix.

@simplynaveen20
Copy link
Member

In mean time you can get unblocked via below.
var query = this.container.GetItemLinqQueryable(true, options).Select(item => item);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working LINQ needs-investigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants