mercredi 6 juillet 2016

Document DB query

I'm trying to query one of my documents from documentDB but it doesn't appear to be working, this is how i set it up:

NoSQLService:

private INoSQLProvider client;
private static IContainer container;


    public NoSQLService(INoSQLProvider provider)
    {
        client = provider;
    }

public static dynamic QueryDocument<T>(Uri reference, FeedOptions queryOptions)
        {
            var documentDB = container.Resolve<INoSQLProvider>();
            return documentDB.QueryDocumentAsync(reference, queryOptions);
        }

INoSQLProvider:

IOrderedQueryable<Document> QueryDocumentAsync(Uri reference, FeedOptions queryOptions);

AzureDocumentDBService

AzureDocumentDBService inherits from INoSQLProvider

private readonly IDocumentClient client;

public IOrderedQueryable<Document> QueryDocumentAsync (Uri reference, FeedOptions queryOptions)
        {
            return client.CreateDocumentQuery(reference, queryOptions);
        }

AzureDocumentDBTest

 FeedOptions queryOptions = new FeedOptions();

        Documents document = new Documents();

        document.id = "112";

        queryOptions.MaxItemCount = -1;

        var reference = NoSQLService.CreateDocumentUri("ppsession1", "callumtest");
        IQueryable<Documents> documentQuery = NoSQLService.QueryDocument<Documents>(reference, queryOptions).Where(document.id = "112");

        foreach (Documents documents in documentQuery)
        {
            Console.WriteLine("\tRead {0}", documents);

        }

When i run the test i get an exception:

Microsoft,CSparp.RuntimeBuilder.RuntimeBinderException: 'object' does not contain a definition for 'Where'.

Aucun commentaire:

Enregistrer un commentaire