【发布时间】:2016-04-14 14:30:54
【问题描述】:
调用 sproc 可以正常工作,但我似乎无法将参数传递给它。它在 Azure 门户中按预期工作,但在从 .net 调用时却不能。
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 调用时的输出是“[object Object]no docs found!”我希望 [Object Object] 是我的参数值。如果我删除参数限制,我会得到一个正确的结果集。此外,如果我使用 azure 中的参数运行它,我会得到正确的结果集。
提前谢谢。
【问题讨论】:
标签: .net stored-procedures azure-cosmosdb