运行 一个原始的 mycouch 查询
run a primitive mycouch query
我是 couchdb 和 mycouch 的新手。我正在尝试实现一个非常简单的查询,我只想获取视图的结果并将其保存到我的 DTO class.
当我通过 HTTP 手动查询时,我的 couchdb 查询有效:
http://localhost:5984/mydb/_design/tshirts/_view/getAllTshirts
但是,当我尝试使用 mycouch 从我的应用程序 运行 连接它时,我无法 运行 它。我当前的查询:
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);
}
由于某种原因,它找不到 Client
class。我找到了一个示例,其中 Client
用于 github,如您所见,我正在使用示例中的所有 MyCouch
相关命名空间。
我也尝试过使用 MyCouchStore
代替:
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);
}
但是,store
不包含任何名为 Views
的 属性。
关于如何使用 MyCouch 查询我的视图有什么想法吗?
显然,文档不是最新的。构造函数现在需要 2 个参数,第二个是可选的引导程序。这对我有用:
var client = new Client("http://localhost:5984/samples", null)
这就是我使用 MyCouchStore 所做的
using (var store = new MyCouchStore("http://user:password@localhost:5984", "samples")) {
var query = new Query("tshirts", "getAllTshirts");
var rows = store.QueryAsync<TShirt>(query).Result;
}
我是 couchdb 和 mycouch 的新手。我正在尝试实现一个非常简单的查询,我只想获取视图的结果并将其保存到我的 DTO class.
当我通过 HTTP 手动查询时,我的 couchdb 查询有效:
http://localhost:5984/mydb/_design/tshirts/_view/getAllTshirts
但是,当我尝试使用 mycouch 从我的应用程序 运行 连接它时,我无法 运行 它。我当前的查询:
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);
}
由于某种原因,它找不到 Client
class。我找到了一个示例,其中 Client
用于 github,如您所见,我正在使用示例中的所有 MyCouch
相关命名空间。
我也尝试过使用 MyCouchStore
代替:
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);
}
但是,store
不包含任何名为 Views
的 属性。
关于如何使用 MyCouch 查询我的视图有什么想法吗?
显然,文档不是最新的。构造函数现在需要 2 个参数,第二个是可选的引导程序。这对我有用:
var client = new Client("http://localhost:5984/samples", null)
这就是我使用 MyCouchStore 所做的
using (var store = new MyCouchStore("http://user:password@localhost:5984", "samples")) {
var query = new Query("tshirts", "getAllTshirts");
var rows = store.QueryAsync<TShirt>(query).Result;
}