Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

NullReferenceException: Object reference not set to an instance of an object. #7

@RajneeshVerma

Description

@RajneeshVerma

I just tried "Quick-start" sample for .net Core and integrated in .NET Core 2.0 App and I am getting error as:
An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an object.
Test.DocumentDBRepository+d__6.MoveNext() in DocumentDBRepository.cs, line 43

Note: The same code is working perfectly in .NET Core V1 with run-time 1.0.4

NullReferenceException: Object reference not set to an instance of an object.
Test.DocumentDBRepository+d__6.MoveNext() in DocumentDBRepository.cs
+
IDocumentQuery query = client.CreateDocumentQuery(
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Test.Controllers.ItemController+d__0.MoveNext() in ItemController.cs
+
var items = await DocumentDBRepository.GetItemsAsync(d => !d.Completed);
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
System.Runtime.CompilerServices.TaskAwaiter.GetResult()
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__12.MoveNext()
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__10.MoveNext()

Code:

public static async Task<IEnumerable<T>> GetItemsAsync(Expression<Func<T, bool>> predicate)
        {
            IDocumentQuery<T> query = client.CreateDocumentQuery<T>(
                UriFactory.CreateDocumentCollectionUri(DatabaseId, CollectionId),
                new FeedOptions { MaxItemCount = -1 })
                .Where(predicate)
                .AsDocumentQuery();
            List<T> results = new List<T>();
            while (query.HasMoreResults)
            {
                results.AddRange(await query.ExecuteNextAsync<T>());
            }

            return results;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions