123456789101112131415161718192021222324252627 |
- using Microsoft.EntityFrameworkCore;
- using MongoDB.Driver;
- using System;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace BookStore
- {
- public class BookStoreContext : DbContext
- {
- private IMongoDatabase _db { get; set; }
- private MongoClient _mongoClient { get; set; }
- public BookStoreContext()
- {
- _mongoClient = new MongoClient(ConfigurationManager.ConnectionStrings["BookStore"].ConnectionString);
- _db = _mongoClient.GetDatabase(ConfigurationManager.ConnectionStrings["BookStore"].Name);
- }
- public IMongoCollection<T> GetCollection<T>(string nameCollection)
- {
- return _db.GetCollection<T>(nameCollection);
- }
- }
- }
|