程序问答   发布时间:2022-06-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了错误:命令 getMore 失败。原因:(未将对象引用设置为对象的实例。)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决错误:命令 getMore 失败。原因:(未将对象引用设置为对象的实例。)?

开发过程中遇到错误:命令 getMore 失败。原因:(未将对象引用设置为对象的实例。)的问题如何解决?下面主要结合日常开发的经验,给出你关于错误:命令 getMore 失败。原因:(未将对象引用设置为对象的实例。)的解决方法建议,希望对你解决错误:命令 getMore 失败。原因:(未将对象引用设置为对象的实例。)有所启发或帮助;

我在通过排序查询 MongoDB 时遇到了这个问题。

@H_44_5@mongoDB.Driver.MongoCommandException: Command getMore Failed: [ActivityID=f840b650-9663-404e-9d74-ae5a4f02b06a] Error=1,Details='Response status code does not inDicate success: InternalServerError (500); Substatus: 0; ActivityID: 00000000-0000-0000-0000-000000000000; Reason: (Object reference not set to an instance of an object.);.
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandmessageWireProtocol`1.ProcessResponse(ConnectionID connectionID,Commandmessage responsemessagE)
   at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandmessageWireProtocol`1.ExecuteAsync(IConnection connection,CancellationToken cancellationToken)
   at MongoDB.Driver.Core.Servers.Server.ServerChAnnel.ExecuteProtocolAsync[TResult](IWireProtocol`1 protocol,CancellationToken cancellationToken)
   at MongoDB.Driver.Core.operations.Asynccursor`1.ExecuteGetMoreCommandAsync(IChAnnelHandle chAnnel,CancellationToken cancellationToken)
   at MongoDB.Driver.Core.operations.Asynccursor`1.GetNextBatchAsync(CancellationToken cancellationToken)
   at MongoDB.Driver.Core.operations.Asynccursor`1.MoveNextAsync(CancellationToken cancellationToken)
   at MongoDB.Driver.IAsynccursorExtensions.ToListAsync[Tdocument](IAsynccursor`1 source,CancellationToken cancellationToken)
   at MongoDB.Driver.IAsynccursorsourceExtensions.ToListAsync[Tdocument](IAsynccursorsource`1 source,CancellationToken cancellationToken)

我的代码中设置的排序列是updatedDate,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();

但是当我为所有记录的 updatedDate 字段设置值时,查询运行成功

为什么 MongoDB 不支持对缺失列进行排序?

更多信息:

实体类 A

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
} 

.NET 中的 MongoDB 驱动程序版本:2.9.3。 Mongodb 版本:3.6.0, 托管在 Azure(Azure Cosmos DB API for MongoDB)上。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

大佬总结

以上是大佬教程为你收集整理的错误:命令 getMore 失败。原因:(未将对象引用设置为对象的实例。)全部内容,希望文章能够帮你解决错误:命令 getMore 失败。原因:(未将对象引用设置为对象的实例。)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。