MongoDB查询转对象是出错Element '_id' does not match any field or property of class


MongoDB查询转对象是出错Element '_id' does not match any field or property of class

 

解决方法:

1、在实体类加:[BsonIgnoreExtraElements]

2、或者定义public ObjectId _id { get; set; }

例子:

[BsonIgnoreExtraElements]

public class BaseData
    {
        //public ObjectId _id { get; set; }

        public string cNo { get; set; }

        public string customer { get; set; }

        public long batchNo { get; set; }

        public DateTime mDate { get; set; }

        public string mUser { get; set; }
    }


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM