Update Inner Property Dynamically using C# driver

33 views
Skip to first unread message

Tim

unread,
Oct 12, 2012, 4:14:44 AM10/12/12
to mongodb-csharp
I apologize if this has been answered already.

What is the best way to update a document inner property dynamically
using the C# Linq driver, without saving the entire document? I'm
using a repository pattern, and would like to create a generic
repository method, where I pass in the collection type, property, and
value. This would be very useful for updating status properties, etc,
so I don't have to update the entire document after it's already
created.

Thank you for the help,
Tim

Daniele Tassone

unread,
Oct 12, 2012, 4:29:51 AM10/12/12
to mongodb...@googlegroups.com, Tim
Not sure that i have understand your needed, but you set an property in this way.
    this.mongo_collections_user.Update(Query.EQ("_id", your_objectid),
    Update
    .Set("property_name", property_value)
    );

Daniele


Reply all
Reply to author
Forward
0 new messages