Azure-cosmos-dotnet-v3: GetItemLinqQueryable throwing "Value cannot be null. Parameter name: sqlQuerySpec"

Created on 16 Jul 2019  路  2Comments  路  Source: Azure/azure-cosmos-dotnet-v3

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.ToListTSource
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()

LINQ bug needs-investigation

All 2 comments

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wahyuen picture wahyuen  路  4Comments

JeremyLikness picture JeremyLikness  路  7Comments

thomaslevesque picture thomaslevesque  路  7Comments

kirankumarkolli picture kirankumarkolli  路  7Comments

lukasz-pyrzyk picture lukasz-pyrzyk  路  3Comments