我有两个简单的查询,一个使用Id
返回单个结果Document doc = client.CreateDocumentQuery<Document>(entity.CollectionSelfLink,
new FeedOptions()
{
PartitionKey = new PartitionKey(entity.PartitionKey),
}).Where(d => d.Id == entity.Id).AsEnumerable().FirstOrDefault();
获得该文档后,我只需调用doc.ETag
并提供ETag。
接下来,我使用FeedResponse<dynamic>
来获得一些结果。
IDocumentQuery<Document> queryList = client.CreateDocumentQuery<Document>(collectionSelfLink, (SqlQuerySpec)query, new FeedOptions
{
PartitionKey = new PartitionKey(partitionKey),
MaxItemCount = 10,
RequestContinuation = requestContinuation,
}).AsDocumentQuery();
if (queryList.HasMoreResults)
{
FeedResponse<T> feed = await queryList.ExecuteNextAsync<T>();
IList<T> documents = feed.ToList();
}
现在,如果我使用相同的doc.ETag
,我会收到以下错误:找不到ETag并且它通过DocumentDbException
oft.Azure.Documents.QueryResult.GetProperty(String propertyName, Type returnType)\r\n at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)\r\n
SingleEntity和Query返回的文档完全相同。有什么想法会导致这种差异?
答案 0 :(得分:0)
此行FeedResponse<T> feed = await queryList.ExecuteNextAsync<T>();
应为FeedResponse<Document> feed = await queryList.ExecuteNextAsync<Document>();