我正在尝试执行一个简单的查询:
SELECT * FROM c
要执行此查询,我有此代码
var urlDocument = UriFactory.CreateDocumentCollectionUri(_databaseName, collectionName);
using (var client = GetDocumentClientAsync())
{
var taskQuery = Task.Run(
() => client.CreateDocumentQuery(urlDocument, query,
new FeedOptions
{
MaxItemCount = 10,
EnableCrossPartitionQuery = false,
MaxBufferedItemCount = 100,
MaxDegreeOfParallelism = 1
}).ToList());
var querydb = taskQuery.Result;
我尝试了没有辅助任务和其他形式(已经没有FeedOptions)。 我总是收到这个错误:
System.AggregateException was unhandled by user code
HResult=-2146233088
Message=Se han producido uno o varios errores.
Source=mscorlib
StackTrace:
en System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
en System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
en System.Threading.Tasks.Task`1.get_Result()
en Microsoft.Azure.Documents.Linq.DocumentQuery`1.GetEnumerator()
en System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
en System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
en DocumentDbApi.DocumentDbRepository.<>c__DisplayClass17_0.<ExecuteQuery>b__0() en D:\Documentos\Visual Studio 2015\Projects\DatabaseStudio\DocumentDbApi\DocumentDbRepository.cs:línea 181
en System.Threading.Tasks.Task`1.InnerInvoke()
en System.Threading.Tasks.Task.Execute()
InnerException:
ActivityId=80272f2f-03fc-424f-b6cd-089a5e3e03ef
HResult=-2146233088
Message=Message: {"errors":[{"severity":"Error","location":{"start":0,"end":0},"code":"SC1002","message":"Syntax error, unexpected end-of-file."}]}
ActivityId: 80272f2f-03fc-424f-b6cd-089a5e3e03ef, Request URI: /apps/39810a5b-058a-4edb-9502-8ddd6d977eec/services/9170e8c4-983b-45d5-8bdf-5eb5b1400da7/partitions/ed4d1123-d7c5-4d3c-ad13-320875aa8507/replicas/131247462173547477s
RequestCharge=1
Source=Microsoft.Azure.Documents.Client
我没有问题通过id,插入,更新,替换,删除...只用sql查询来做简单的阅读文档。
答案 0 :(得分:0)
我已为其他框架版本安装了Documentdb客户端DLL。现在代码运行正常。 感谢