MongoDB C# Driver: Ignore Property on Insert

前端 未结 5 1659
余生分开走
余生分开走 2021-02-03 18:48

I am using the Official MongoDB C# Drive v0.9.1.26831, but I was wondering given a POCO class, is there anyway to ignore certain properties from getting inserted.

For ex

5条回答
  •  悲哀的现实
    2021-02-03 19:35

    It looks like the [BsonIgnore] attribute did the job.

    public class GroceryList : MongoEntity
    {
        public FacebookList Owner { get; set; }
        [BsonIgnore]
        public bool IsOwner { get; set; }
    }
    

提交回复
热议问题