首页 新闻 会员 周边

C#在MongoDB添加数据报错

1
悬赏园豆:100 [已解决问题] 解决于 2015-04-16 10:45

The property '_id' of type 'WeChatWall.Models.Entity.WXChatUser' cannot use element name '_id' because it is already being used by property '_id' of type 'WeChatWall.Common.Models.LibEntity'.

LibEntity

 

    public class WXChatUser : LibEntity
    {
        [PrimaryKey]
        public long UserId { get; set; }

        /// <summary>
        /// 聊天昵称,可用来at
        /// </summary>
        public string NickName { get; set; }

        /// <summary>
        /// 头像上传后保存的路径
        /// </summary>
        public string PhotoPath { get; set; }

        /// <summary>
        /// 用户邮箱,以后用来发通知
        /// </summary>
        public string Email { get; set; }

        /// <summary>
        /// 用户手机,用来发通知或做抽奖
        /// </summary>
        public string Mobile { get; set; }

        /// <summary>
        /// 当前所在的房间Id
        /// </summary>
        public string CurrentRoomId { get; set; }

        /// <summary>
        /// 当前正在编辑的ArticleId
        /// </summary>
        public string CurrentArticleId { get; set; }

        /// <summary>
        /// 值为1时是男性,值为2时是女性,值为0时是未知
        /// </summary>
        public int Sex { get; set; }

        public string City { get; set; }

        public string Province { get; set; }

        public string Country { get; set; }

        /// <summary>
        /// 用户最后上报的地理位置
        /// </summary>
        public double Latitude { get; set; }

        public double Longitude { get; set; }

        public float Precision { get; set; }

        /// <summary>
        /// 首次加入的时间
        /// </summary>
        [BsonDateTimeOptions(Kind = DateTimeKind.Local), JsonConverter(typeof(IsoDateTimeConverter))]
        public DateTime AddTime { get; set; }

        /// <summary>
        /// 
        /// </summary>
        [BsonDateTimeOptions(Kind = DateTimeKind.Local), JsonConverter(typeof(IsoDateTimeConverter))]
        public DateTime UpdateTime { get; set; }

        /// <summary>
        /// 是否接收私信
        /// </summary>
        public bool RecieveLetter { get; set; }

        public long _31UserId { get; set; }

        public int Status { get; set; }
        public int IsCheck { get; set; }

        public int IsBlack { get; set; }
        public int IsLucky { get; set; }

    }

 

 

麻烦各位大神帮忙看下

Jerome.Sung的主页 Jerome.Sung | 初学一级 | 园豆:68
提问于:2015-04-15 19:09
< >
分享
最佳答案
1

问题已经解决了,实际上是子类的 UpdateTime 和父类的 UpdateTime 重复了,但是VS的报错提示是 _id 属性,也就是错误提示和实际错误不准确

Jerome.Sung | 初学一级 |园豆:68 | 2015-04-16 10:44
其他回答(1)
0

你在下面那个类,加上[Serializable, JsonObject(MemberSerialization.OptOut)]呢,看错误消息,感觉像是继承的原因导致的。

收获园豆:100
幻天芒 | 园豆:37175 (高人七级) | 2015-04-16 09:13

也不是这个原因,这个我加上后也还出现这种问题

支持(0) 反对(0) Jerome.Sung | 园豆:68 (初学一级) | 2015-04-16 10:43

@Jerome.Sung: 这个错误提示也太坑人了吧。。

支持(0) 反对(0) 幻天芒 | 园豆:37175 (高人七级) | 2015-04-16 11:06

@幻天芒: 是的,被错误提示坑了

支持(0) 反对(0) Jerome.Sung | 园豆:68 (初学一级) | 2015-04-17 09:21

@Jerome.Sung: :),踩坑,让你下次远离坑。

支持(0) 反对(0) 幻天芒 | 园豆:37175 (高人七级) | 2015-04-17 09:29
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册