C# 错误:getMore命令失败。原因:(对象引用未设置为对象的实例。)
我在使用排序查询MongoDB时遇到了这个问题C# 错误:getMore命令失败。原因:(对象引用未设置为对象的实例。),c#,mongodb,azure-cosmosdb-mongoapi,C#,Mongodb,Azure Cosmosdb Mongoapi,我在使用排序查询MongoDB时遇到了这个问题 MongoDB.Driver.MongoCommandException:命令getMore失败:[ActivityId=f840b650-9663-404e-9d74-ae5a4f02b06a]错误=1,详细信息=”响应状态代码不表示成功:InternalServerError(500);子状态:0;活动ID:00000000-0000-0000-0000-00000000;原因:(对象引用未设置为对象的实例。);。 在MongoDB.Drive
MongoDB.Driver.MongoCommandException:命令getMore失败:[ActivityId=f840b650-9663-404e-9d74-ae5a4f02b06a]错误=1,详细信息=”响应状态代码不表示成功:InternalServerError(500);子状态:0;活动ID:00000000-0000-0000-0000-00000000;原因:(对象引用未设置为对象的实例。);。
在MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ProcessResponse(ConnectionId ConnectionId,CommandMessageResponseMessage responseMessage)
在MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection,CancellationToken CancellationToken)
在MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocolAsync[TResult](IWireProtocol`1协议,CancellationToken CancellationToken)
在MongoDB.Driver.Core.Operations.AsyncCursor`1.ExecuteGetMoreCommandAsync(IChannelHandle通道,CancellationToken CancellationToken)
在MongoDB.Driver.Core.Operations.AsyncCursor`1.GetNextBatchAsync(CancellationToken CancellationToken)
在MongoDB.Driver.Core.Operations.AsyncCursor`1.MoveNextAsync(CancellationToken CancellationToken)
在MongoDB.Driver.iasyncursorextensions.toListSync[TDocument](iasyncursor`1源,CancellationToken CancellationToken)
在MongoDB.Driver.iasyncursorsourceextensions.toListSync[TDocument](iasyncursource`1 source,CancellationToken CancellationToken)
我的代码中设置的排序列为updateDate,DESC,数据库集合中缺少此列
var collections = _mongoDatabase.GetCollection<T>(typeof(T).Name.ToLower());
if (filterCondition == null)
{
filterCondition = Builders<T>.Filter.Empty;
}
return await collections
.Find(filterCondition ?? FilterDefinition<T>.Empty, new FindOptions() { Collation = new Collation("en", strength: CollationStrength.Secondary) })
.Sort(sortDefinition)
.ToListAsync();
.NET中的MongoDB驱动程序版本:2.9.3。Mongodb版本:3.6.0,
它托管在Azure(Azure Cosmos DB API for MongoDB)上。MongoDB可以对缺少的列进行排序,这应该是驱动程序的问题。见:
class A {
public string Name {get;set;}//always having value
public string CreatedDate {get;set;} // always having value
public string UpdatedDate{get;set;} // missing in database
}