Couchbase .Net Library complex startKey/endKey typ

2019-09-18 11:03发布

问题:

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

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

In LINQ this query look like this:

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

What type should be variables startKey and endKey?

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

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

回答1:

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

I've finally find types for my LINQ variables:

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

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

and query: >

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