oqq__L 2021-09-09 16:19 采纳率: 100%
浏览 43
已结题

C#操作mongodb时,find无法序列号报错

public  class drgs_report_data
    {
        public ObjectId _id;
        public string reportContent{ get; set; }
       // public object reportContent { get { return string.Empty; } set { reportContent = string.Empty; } }
        public string _class { get; set; }
        public Int64 diseaseId { get; set; }   
        public int caseId { get; set; }
        public DateTime auditTime { get; set; }  //
        public string bigDepartment { get; set; }  
        public string chargeDoctor{ get; set; }
        public DateTime createTime { get; set; }  //
        public int dataState { get; set; }
        public DateTime dataTime { get; set; }//
}
public List<T> FindAllMore<T>() 
        {
            List<T> list = new List<T>();
            try
            {

                list = this._db.GetCollection(typeof(T).Name).FindAllAs<T>().ToList();//执行这里的时候异常了
            }
            catch (Exception ex)
            {

            }
            return list;
        }

异常信息如下:reportContent 这个字段string 的不能序列号,,请问这个要怎么改??
An error occurred while deserializing the reportContent property of class MongodbHelper.Model.drgs_report_data: Cannot deserialize string from BsonType Document.

  • 写回答

2条回答 默认 最新

  • CSDN专家-showbo 2021-09-09 16:45
    关注

    BSON是用于在MongoDB中存储文档和进行远程过程调用的二进制序列化格式


    public string reportContent{ get; set; }
    改为
    public byte[] reportContent{ get; set; }

    试试

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月18日
  • 已采纳回答 9月10日
  • 创建了问题 9月9日

悬赏问题

  • ¥15 这种微信登录授权 谁可以做啊
  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来