Views using .Key(.....) returns no results


Hi I want to use a complex object as a key in my view

my documents are stored as json.

“projectId”: {
“id”: “85e0d814-071e-4c7d-9369-5b46fc3935aa”

I want to find documents by ProjectId which is a class with an Id property. I want to encapsulate my ids as value objects. But I might end up using simple strings if i cannot make this work.

the view is defined like this:

function(doc,meta) { if(doc.type=="projecttask" && doc.projectId) { emit(doc.projectId,null); } }

querying the view from management web site gives:


using the following code in .net sdk works fine

var view = Client.GetView(_designDoc, “by_project”, true);

it gives me all 12 rows.

How ever i’m only interested in those that match a particular projectId.

So I added the .Key method

var view = Client.GetView(_designDoc, “by_project”, true).Key(projectId);

this gives no result. also tried using

var view = Client.GetView(_designDoc, “by_project”, true).Key(projectIdAsJson);


var view = Client.GetView(_designDoc, “by_project”, true).Key(projectIdAsJson);

I also tried using the generic version of GetView.
Nothing helps.

Any Ideas?

ultimately i would like to use

var result = Client.GetView(_designDoc, “by_project”, true).Key(projectId);

Another question how would one use
the generic Version of Key with a multivalue key? like object[]{type1, type2} ?



Hi ccjohansen -

If projectId is a primary key you could just do a regular Get(projectId)? This doesn’t actually answer your question of why Key(…) isn’t working…i’ll have to run through the code.



No its not the primary key.