C# DocumentDb select正在处理QueryExplorer,但未在我的代码中返回正确的结果

C# DocumentDb select正在处理QueryExplorer,但未在我的代码中返回正确的结果,c#,azure,azure-cosmosdb,C#,Azure,Azure Cosmosdb,对于我存储在DocumentDb数据库中的以下JSON对象,我创建了一个SELECT查询,并使用查询资源管理器在Azure Portal上对其进行了测试。我在门户上得到的结果是正确的 然后,我在代码中使用相同的精确查询-使用DocumentDb客户端,结果并不完全正确 下面是存储在DocumentDb中的完整JSON文档 { id: 987456, name: "Jerry Buss Family Trust", sportsTeams: [ {

对于我存储在DocumentDb数据库中的以下JSON对象,我创建了一个SELECT查询,并使用查询资源管理器在Azure Portal上对其进行了测试。我在门户上得到的结果是正确的

然后,我在代码中使用相同的精确查询-使用DocumentDb客户端,结果并不完全正确

下面是存储在DocumentDb中的完整JSON文档

{
   id: 987456,
   name: "Jerry Buss Family Trust",
   sportsTeams: [
      {
         id: 123,
         type: "Professional Basketball Team",
         team: "Los Angeles Lakers",
         coach: "Byron Scott",
         players: [
            {
                id: 2,
                name: "Brandon Bass",
                position: "Forward"
            },
            {
                id: 24,
                name: "Kobe Bryant",
                position: "Forward-Guard"
            },
            {
                id: 4,
                name: "Ryan Kelly",
                position: "Forward"
            }
         ]
      },
      {
         id: 345,
         type: "Professional Hockey Team"
         team: "Los Angeles Kings",
         coach: "Darryl Sutter",
         players: [
            {
                id: 15,
                name: "Andy Andreoff",
                position: "Forward"
            },
            {
                id: 27,
                name: "Alec Martinez",
                position: "Defenseman"
            },
            {
                id: 32,
                name: "Jonathan Quick",
                position: "Goalie"
            }
         ]
      }
   ]
}
我只想得到杰里·巴斯家族信任文件下的运动队。以下是我的SQL:

SELECT c.id as teamId, c.name as teamName, c.players
FROM a JOIN c in a.sportsTeams
WHERE a.id = "987456"
当我在Azure Portal Query Explorer上运行此操作时,我从主文档和所有玩家的数组中获得了我想要的id和名称

但是,当我在代码中使用此查询时,我在players数组中获得了主记录和正确的项数,但每个数组项都有空值。所以我得到了这样的结果:

{
   id: 123,
   name: "Los Angeles Lakers"
   players: [
       {
           id: 0
           name: NULL,
           position: NULL
       },
       // etc. IMPORTANT: I do get the CORRECT number of sub-documents that correspond to players.
       // Also note that the shape of the sub document is correct.
       // The issue is that the data is missing!
   ]
}
执行读取查询的代码如下所示:

public async Task<IEnumerable<T>> ReadQuery<T>(string collectionId, SqlQuerySpec sql)
{
    var collectionLink = UriFactory.CreateDocumentCollectionUri(_dbName, collectionId);

    var result = _client.CreateDocumentQuery<T>(collectionLink, query, null).ToList();
    return result;
}
在这段代码运行之后,我正在检查结果,正如我所说的,我确实正确地获得了主文档数据。我还获得了子文档的正确数量/形状,但子文档中没有任何数据


知道是什么导致了这个问题吗?

您能展示一下定义T类型的代码吗?我通常总是使用类型来避免在更改模式时出现键入问题。你可能想试试。同意@LarryMaccherone,对我来说听起来像是一个去序列化错误。您获得了正确的结果集,但代码中的对象似乎没有正确填充。这是正确的吗?你能用类似于Fiddler的东西检查电线响应来验证吗。