DocumentDb CreateDocumentQuery 停止工作

DocumentDb CreateDocumentQuery stopped working

我有这个方法:

/// <summary>
/// Gets a list of our documents
/// </summary>
/// <returns></returns>
public List<T> List(string query)
{
    // Return our items
    return this._client.CreateDocumentQuery<T>(UriFactory.CreateDocumentCollectionUri(this._databaseName, this._collectionName), query).ToList();
}

直到今天,它一直运行良好。 现在它抛出一个错误:

Partition routing information cannot be extracted from the query when running in a 32-bit process. To complete your query and avoid this exception, ensure that your host process is 64-bit.\r\nFor Executable applications, this can be done by unchecking the \"Prefer 32-bit\" option in the project properties window, on the Build tab. \r\nFor VSTest based test projects, this can be done by selecting Test->Test Settings->Default Processor Architecture as X64, from Visual Studio Test menu option.\r\nFor locally deployed ASP.NET Web applications, this can be done by checking the \"Use the 64 bit version of IIS Express for web sites and projects\", under Tools->Options->Projects and Solutions->Web Projects.\r\n

这真的很奇怪,因为我这边什么都没有改变。 我尝试了它所说的一切,但无济于事,它仍然有错误。 有谁知道为什么?

可以找到有关此错误消息的一些信息 here

如果您不使用 DocumentDb 中的分区路由功能,您可以更改代码以提供 FeedOptions 以禁用 EnableCrossPartitionQuery

/// <summary>
/// Gets a list of our documents
/// </summary>
/// <returns></returns>
public List<T> List(string query)
{
    // Return our items
    return
        this
          ._client
          .CreateDocumentQuery<T>(
               UriFactory.CreateDocumentCollectionUri(this._databaseName, this._collectionName), 
               query,
               new FeedOptions { EnableCrossPartitionQuery = false };
          ).ToList();
}