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 example, I have the following class:
public class GroceryList
{
public string Name { get; set; }
public FacebookList Owner { get; set; }
public bool IsOwner { get; set; }
}
Is there a way, for the IsOwner to not get inserted when I insert a GroceryList object? Basically, I fetch the object from the database then set the IsOwner property in the app layer and then return it back to the controller, which than maps the object to a view model.
Hope my question makes sense. thanks!
It looks like the [BsonIgnore] attribute did the job.
public class GroceryList : MongoEntity<ObjectId>
{
public FacebookList Owner { get; set; }
[BsonIgnore]
public bool IsOwner { get; set; }
}