Couchbase .Net库复杂的startKey/endKey类型 [英] Couchbase .Net Library complex startKey/endKey types

查看:44
本文介绍了Couchbase .Net库复杂的startKey/endKey类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将这些参数从REST-API查询转换为C#LINQ.

I need to convert those params from REST-API query to C# LINQ.

?descending = true& endkey = [35,37]& startkey = [35,37,{}]

?descending=true&endkey=[35,37]&startkey=[35,37,{}]

在LINQ中,此查询如下:

In LINQ this query look like this:

c.GetView("MyView","SubView").StartKey(startKey).EndKey(endKey).Descending(true);

c.GetView("MyView", "SubView").StartKey(startKey).EndKey(endKey).Descending(true);

变量startKey和endKey应该是什么类型?

What type should be variables startKey and endKey?

我已经尝试过字符串,但是在这种情况下,.Net库会生成带有无效参数的查询:

I've tried string, but in this case .Net library produces query with invalid params:

?descending = true& endkey ="[35,37]"& startkey ="[35,37,{}]"

?descending=true&endkey="[35,37]"&startkey="[35,37,{}]"

推荐答案

我进行了一些研究并找到了答案.根据 https://github.com/couchbase/couchbase-net-client/blob/master/src/Couchbase/CouchbaseViewBase.cs#L320

I've done some research and found the answer. Acording to https://github.com/couchbase/couchbase-net-client/blob/master/src/Couchbase/CouchbaseViewBase.cs#L320

我终于找到了我的LINQ变量的类型:

I've finally find types for my LINQ variables:

object [] startKey = new object [] {35,37,"{}"};

object[] startKey = new object[] { 35, 37, "{}" };

object [] endKey =新对象[] {35,37};

object[] endKey = new object[] { 35, 37};

并查询:>

c.GetView("MyView","SubView").StartKey(startKey).EndKey(endKey).Descending(true);

c.GetView("MyView", "SubView").StartKey(startKey).EndKey(endKey).Descending(true);

这篇关于Couchbase .Net库复杂的startKey/endKey类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆