2023-05-09 22:54:35 +04:00
|
|
|
|
using MongoDB.Driver;
|
|
|
|
|
using System;
|
2023-05-09 15:00:49 +04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace TransportCompamyMongoDBImplementer
|
|
|
|
|
{
|
|
|
|
|
public class DBMSContext
|
|
|
|
|
{
|
2023-05-10 17:32:24 +04:00
|
|
|
|
private const string ConnectionString = "mongodb://127.0.0.1:27017";
|
2023-05-09 22:54:35 +04:00
|
|
|
|
|
|
|
|
|
private const string DatabaseName = "transportcompany";
|
|
|
|
|
|
|
|
|
|
public IMongoCollection<T> ConnectToMongo<T>(in string collection)
|
|
|
|
|
{
|
|
|
|
|
var client = new MongoClient(ConnectionString);
|
|
|
|
|
var db = client.GetDatabase(DatabaseName);
|
|
|
|
|
|
|
|
|
|
return db.GetCollection<T>(collection);
|
|
|
|
|
}
|
2023-05-09 15:00:49 +04:00
|
|
|
|
}
|
|
|
|
|
}
|