Код: Выделить всё
{
"_id": {
"$oid": "6*********************0"
},
"Username": "a",
"Password": "a",
"Blacklist": [
"example5",
"example6",
"example7",
"example8",
"example9",
"example10"
],
"Whitelist": [
"example"
]
}
Код: Выделить всё
private readonly MongoDBIDService mongoIDService;
private async void UpdateBList3()
{
blockedList.Clear();
var user = await mongoIDService.GetUser(userID);
if (user != null)
{
Log(user.ToJson());
}
else
{
Log("User is null");
}
}
Код: Выделить всё
public class MongoDBIDService
{
private readonly IMongoCollection users;
public MongoDBIDService(string connectionString, string databaseName, string collectionName)
{
var client = new MongoClient(connectionString);
var database = client.GetDatabase(databaseName);
users = database.GetCollection(collectionName);
}
public async Task GetUser(string id)
{
var userFilter = Builders.Filter.Eq("Id", id);
return await users.Find(userFilter).FirstOrDefaultAsync();
}
}
Код: Выделить всё
public class User
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public List Blacklist { get; set; }
public List Whitelist { get; set; }
public User()
{
Blacklist = new List();
Whitelist = new List();
}
}
Код: Выделить всё
Exception thrown: 'MongoDB.Driver.MongoConnectionException' in MongoDB.Driver.dll,
Exception thrown: 'System.MissingMethodException' in MongoDB.Bson.dll,
Exception thrown: 'System.MissingMethodException' in MongoDB.Driver.dllПодробнее здесь: https://stackoverflow.com/questions/793 ... de-c-sharp
Мобильная версия