Ejemplo n.º 1
0
        public EFGeneric_multiDBProvider_RepositoryImplementation()
        {
            // DI IOC container will come here
            _context = new bookMeDBContext();
            //_context = bookMeDBContext.bookMeDBContextNonSingeltonFactory();

            _context.Database.Log = Console.Write;
        }
Ejemplo n.º 2
0
        public EFGeneric_CommandImplementation(bookMeDBContext dbContextInjection)
        {
            // DI IOC container will come here
            _context = dbContextInjection;
            _context.Database.Log = Console.Write;

            //_context = bookMeDBContext.bookMeDBContextSingeltonFactory();
            //_context = bookMeDBContext.bookMeDBContextNonSingeltonFactory();
        }
Ejemplo n.º 3
0
        public EFGeneric_QueryImplementation(bookMeDBContext dbContextInjection)
        {
            _context = dbContextInjection;
            _context.Database.Log = Console.Write;

            //TODO - add dependency injection IOC controller here !
            //_context = bookMeDBContext.bookMeDBContextSingeltonFactory();
            //_context = bookMeDBContext.bookMeDBContextNonSingeltonFactory();
        }
 // singelton menthod for the only one instance of DB context; this thread safe however.
 // this Approach is now causing Threading issues coz multiple threads are trying to do CRUD using one dbContext instance
 public static bookMeDBContext bookMeDBContextSingeltonFactory()
 {
     if (_singeltonDBContextInstance == null)
     {
         _singeltonDBContextInstance = new bookMeDBContext();
         return(_singeltonDBContextInstance);
     }
     else
     {
         return(_singeltonDBContextInstance);
     }
 }
 //Adding a new Non-singelton FactoryMethod to .solve the Threading isses
 public static bookMeDBContext bookMeDBContextNonSingeltonFactory()
 {
     _singeltonDBContextInstance = new bookMeDBContext();
     return(_singeltonDBContextInstance);
 }