public string ExecTempView(string server, string db, string map, string reduce, string startkey, string endkey)
{
// Generate the JSON view definition from the supplied
// map and optional reduce functions...
string viewdef = "{ \"map\":\"" + map + "\"";
if (reduce != null)
viewdef += ",\"reduce\":\"" + reduce + "\"";
viewdef += "}";
string url = server + "/" + db + "/_temp_view";
if (startkey != null)
{
url += "?startkey=" + System.Web.HttpUtility.UrlEncode(startkey);
}
if (endkey != null)
{
if (startkey == null) url += "?"; else url += "&";
url += "endkey=" + HttpUtility.UrlEncode(endkey);
}
return DoRequest(url, "POST", viewdef, "application/json");
}