我一直在尝试将此语句从 C# 转换为 JAVA,但运气不佳。是的,我搜索了 Azure、stackoverflow 等,但在 java 中找不到 READDOCUMENT 的好例子。
UserInfo response = _DocumentClient.ReadDocument<UserInfo>(UriFactory.CreateDocumentUri(_DBConfiguration.DatabaseID, _DBConfiguration.DocumentCollectionId, pPhoneNumber));
这是据我所知:
UserInfo returnUserInfo = null;
try {
//todo: document link is incorrect, but reference pPhoneNumber as key
ResourceResponse<Document> response = _DocumentClient.readDocument(<<NEED To generate URI>>,null);
if (response != null) {
Document returnUserInfoDocument = response.getResource();
returnUserInfo = <<I have a document, but can't cast it to USERINFO>>;
}
}
catch (DocumentClientException ex) {
if (!ex.getError().getCode().equals("NotFound")) {
throw ex;
}
}
return returnUserInfo;