如何使用c#driver(2.4.4)
在mongodb中整体更新文档protected static IMongoClient _client;
protected static IMongoDatabase _database;
protected static IMongoCollection<UserSetting> _collection;
public DataAccess()
{
_client = new MongoClient("mongodb://localhost:27017");
_database = _client.GetDatabase("usersettings");
_collection = _database.GetCollection<UserSetting>("settings");
}
public void SaveSetting(int Id, UserSetting setting)
{
setting.UserID = Id;
var settingsForID = _database.GetCollection<UserSetting>("settings").AsQueryable<UserSetting>().Where(c => c.UserID == Id);
}