如何使用C#驱动程序更新mongodb中的文档

时间:2017-06-23 08:25:05

标签: c# mongodb

如何使用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);

            }

0 个答案:

没有答案