Sql 查询Cosmos DocumentDB时出现溢出或下溢异常

Sql 查询Cosmos DocumentDB时出现溢出或下溢异常,sql,azure-cosmosdb,Sql,Azure Cosmosdb,我在尝试查询Cosmos DocumentDB时遇到意外错误。我已经在Azure Data Explorer中运行了我的查询,并且得到了预期的结果,但是,当我尝试使用C#SQL API运行它时,我得到了各种错误(在不同的尝试之后),包括“算术运算中的溢出或下溢”或“NullReferenceException”。当我使用ReadDocumentSync时,我得到一个没有错误的文档,所以我知道我的cosmos客户端和集合uri是正常的 有人能帮我理解为什么我会有这个问题吗 以下是我如何构建和执行查

我在尝试查询Cosmos DocumentDB时遇到意外错误。我已经在Azure Data Explorer中运行了我的查询,并且得到了预期的结果,但是,当我尝试使用C#SQL API运行它时,我得到了各种错误(在不同的尝试之后),包括“算术运算中的溢出或下溢”或“NullReferenceException”。当我使用ReadDocumentSync时,我得到一个没有错误的文档,所以我知道我的cosmos客户端和集合uri是正常的

有人能帮我理解为什么我会有这个问题吗

以下是我如何构建和执行查询:

        using (var cosmosClient = new DocumentClient(new Uri(cosmosEndPointUrl), cosmosAuthKey))
        {
            var collectionUri = UriFactory.CreateDocumentCollectionUri(databaseId, collectionId);
            var sql = @"SELECT TOP 10 p.Id As QuoteKey
                ,pol.Proposer.Forename
                ,pol.Proposer.Surname
                ,pol.Proposer.ResidentialAddress.Postcode
                ,veh.Vrn
                FROM Proposal p
                    JOIN pol IN p.QuoteRequest.Policies
                    JOIN veh IN pol.Vehicles
                WHERE(pol.Proposer.Forename = @Forename OR @Forename = '')
                      AND(pol.Proposer.Surname = @Surname OR @Surname = '')
                      AND(pol.Proposer.ResidentialAddress.Postcode = @Postcode OR @Postcode = '')
                      AND(veh.Vrn = @Vrn OR @Vrn = '')";
            var ps = new SqlParameterCollection(new SqlParameter[]
                                                    {
                                                        new SqlParameter { Name = "@Forename", Value = criteria.Firstname }, 
                                                        new SqlParameter { Name = "@Surname", Value = criteria.Surname }, 
                                                        new SqlParameter { Name = "@Postcode", Value = criteria.Postcode }, 
                                                        new SqlParameter { Name = "@Vrn", Value = criteria.RegNo }, 
                                                    });
            var sqlQuerySpec = new SqlQuerySpec(sql, ps);
            var fo = new FeedOptions { MaxItemCount = 10 };
            List<QuoteSummary> results = new List<QuoteSummary>();
            var query = cosmosClient.CreateDocumentQuery(collectionUri, sqlQuerySpec, fo).AsDocumentQuery();
            while (query.HasMoreResults)
            {
                var demiResults = await query.ExecuteNextAsync<QuoteSummary>();
                results.AddRange(demiResults);
            }

            return results.ToList();
        }

请帮忙。这个问题正在蚕食我在微软参加的一次黑客攻击的时间,到目前为止,我问过的人都不知道它为什么不起作用。

当我遇到这个异常时,它与环境+依赖项有关:
我的配置是Azure应用程序服务,它查询Azure cosmosdb。

我缺少的是Web API级别中的。很明显,它作为一个依赖项存在于其他被引用的类库中,但在顶级运行的应用程序(在我的例子中是Web API)中没有被直接引用。

有没有可能长的属性之一为null?e、 g.在
pol.Proposer.ResidentialAddress.Postcode
ResidentialAddress
中为空您是否在Azure数据资源管理器中执行了完全相同的查询?你有一些自定义索引吗?我检查了索引设置,只使用默认值,它会自动索引所有数字和字符串字段。我们构建的数据生成器工具创建了包含Proposer、Vehicles和ResidentialAddress的完全填充的提案,因此所有嵌套属性都不应为null。我现在想看看是否可以找出是否正在使用索引,或者是否可以启用某种跟踪。当您收到NullReferenceException时,您可能可以从exception跟踪什么var为null,对吗?
public class QuoteSummary
{
    public string QuoteKey { get; set; }
    public string Forename { get; set; }
    public string Surname { get; set; }
    public string Postcode { get; set; }
    public string Vrn { get; set; }
}
public class QuoteSearchCriteria
{
    public string Firstname { get; set; }
    public string Surname { get; set; }
    public string Postcode { get; set; }
    public string RegNo { get; set; }
}