MongoDB查询转对象是出错Element ‘_id’ does not match any field or property of class – 94cool – 博客园 -Mikel

MongoDB查询转对象是出错Element ‘_id’ does not match any field or property of class – 94cool – 博客园

2020年9月9日 分类: C#, Debug, 数据库
baacloud免费翻墙vpn注册使用

来源: MongoDB查询转对象是出错Element ‘_id’ does not match any field or property of class – 94cool – 博客园

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; }
}






标签:
本文的评论功能被关闭了.
备案信息冀ICP 0007948