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