.Net library LINQ complex keys
I need to implement such REST query in LINQ:
?descending=true&endkey=[35,37]&startkey=[35,37,{}]In LINQ it looks like:
c.GetView("MyView", "SubView").StartKey(startKey).EndKey(endKey).Descending(true);Where startKey and endKey are variables.
The question is "how to define those variables to produce query similar to first code block?"
I've tried to define startKey and endKey as strings, but in those case library generates query with invalid params
?descending=true&endkey="[35,37]"&startkey="[35,37,{}]"PS: .net library version 1.2, couchbase 2.0
There is an (admittedly brief) example of working with array keys at http://www.couchbase.com/docs/couchbase-sdk-net-1.2/api-reference-view.html. See the "by_name_and_abv" example.
You can also review the patch that is posted to http://review.couchbase.org/#patch,sidebyside,16719,1,src/Couchbase.Test... for a look at serialization tests for the key arguments.
Long story short, key params are just JSON serialized values.
This patch still needs to be merged into the master branch. That should happen in the next few days, at which time I'll package up another build.
-- John
One other note... Just to be clear, there isn't actually a LINQ implementation with the .NET client. These methods are fluent and LINQ-like in that they will modify the query execution before you iterate over the view, but you won't get an IQueryable back. So if you were to try to chain LINQ methods (i.e., Select() or Where()) to the call, you'd first be executing the query and then filtering the results.
Ok. I've digged deeper. So acording to https://github.com/couchbase/couchbase-net-client/blob/master/src/Couchb...
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<Array>(startKey).EndKey<Array>(endKey).Descending(true);It would be nice, if someone add this note to documentation. I can provide more detailed example if it is necessary.