Ronin Ronin - 18 days ago 10
C# Question

run a primitive mycouch query

I'm new to couchdb and mycouch. I'm trying to implement a very simple query, I just want to get the results of a view and save it into my DTO class.

My couchdb query works, when I query it manually via HTTP:

http://localhost:5984/mydb/_design/tshirts/_view/getAllTshirts


However, when I try running it from my app using mycouch, I can't get to run it. My current query:

using MyCouch.Requests;
using MyCouch.Responses;

// (...)

using (var client = new Client("http://localhost:5984/samples")) {
var query = new QueryViewRequest("getAllTshirts");

ViewQueryResponse<TShirt[]> result = await client.Views.QueryAsync<TShirt[]>(query);
Console.WriteLine (result);
}


For some reason, it won't find the
Client
class. I found an example where
Client
is used on github, as you can see, I'm using all the
MyCouch
related namespaces as in the example.

I also tried using
MyCouchStore
instead:

using (var store = new MyCouchStore("http://localhost:5984/", "samples")) {
var query = new QueryViewRequest("getAllTshirts");
ViewQueryResponse<TShirt[]> result = await store.Views.QueryAsync<TShirt[]>(query);
Console.WriteLine (result);
}


However, the
store
doesn't contain any property named
Views
.
Any ideas how to query my view using MyCouch?

Answer

Apparantely, the documentation was not up to date. The constructor requires now 2 arguments, the second being an optional bootstrapper. This worked for me:

var client = new Client("http://localhost:5984/samples", null)
Comments