1
調用sproc工作正常,但我似乎無法傳遞參數給它。它可以在Azure門戶中按預期工作,但不會在.NET中調用。使用參數從.Net調用DocumentDb存儲過程。
documentClient = new DocumentClient(new Uri(endpointUrl), authorizationKeyAdmin);
var sproc = documentClient.CreateStoredProcedureQuery(_companyCollection.StoredProceduresLink, "select * from root r where r.id = \"testSproc\"");
var result = documentClient.ExecuteStoredProcedureAsync<string>("dbs/GypNAB==/colls/GxpNAKrZMwA=/sprocs/GxpNAKrZMwxxxxAAAAAAAgA==/", sproc, "MyParameter");
的存儲過程並沒有什麼變化
function sample(rrid) {
var collection = getContext().getCollection();
// Query documents and take 1st item.
var isAccepted = collection.queryDocuments(
collection.getSelfLink(),
'SELECT top 1 * FROM c where c.RRID = "'+rrid+'"',
function (err, feed, options) {
if (err) throw err;
// Check the feed and if empty, set the body to 'no docs found',
// else take 1st element from feed
if (!feed || !feed.length) getContext().getResponse().setBody(rrid + 'no docs found!');
else getContext().getResponse().setBody(JSON.stringify(feed[0]));
});
if (!isAccepted) throw new Error('The query was not accepted by the server.');
}
從.NET調用時輸出爲「的翻譯:沒有找到文檔!」我希望[對象對象]是我的參數值。如果我刪除參數限制,我會得到一個適當的結果集。另外,如果我用azure中的參數運行它,我會得到一個適當的結果集。
提前致謝。
UG,感謝名單。猜猜我是以一個壞榜樣爲基礎的代碼。也許你可以解釋一下,我已經看到了幾個例子,首先從片名選擇*。這是否應該用於獲取sproc ID,或者這樣做的目的是什麼? – VirtualLife
當DocumentDB發佈時,它要求所有資源都由系統生成的'_self'鏈接引用......這可能是舊樣本的基礎。大約半年前,由用戶定義的「id」進行路由 - 通過id查詢資源冗餘。 –