init
This commit is contained in:
31
DouyinApi.Repository/MongoRepository/MongoDbContext.cs
Normal file
31
DouyinApi.Repository/MongoRepository/MongoDbContext.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
using DouyinApi.Common;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace DouyinApi.Repository.MongoRepository
|
||||
{
|
||||
|
||||
public class MongoDbContext
|
||||
{
|
||||
private readonly IMongoDatabase _database = null;
|
||||
|
||||
public MongoDbContext()
|
||||
{
|
||||
var client = new MongoClient(AppSettings.app(new string[] { "Mongo", "ConnectionString" }));
|
||||
_database = client.GetDatabase(AppSettings.app(new string[] { "Mongo", "Database" }));
|
||||
}
|
||||
|
||||
public IMongoDatabase Db
|
||||
{
|
||||
get { return _database; }
|
||||
}
|
||||
|
||||
//public IMongoCollection<TEntity> Query
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return _database.GetCollection<TEntity>(nameof(TEntity));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user