Beispiel #1
0
        public static IBookDao GetBookDao(string connectionString)
        {
            IBookDao bookDao;

            if (_bookDaoCache.TryGetValue(connectionString, out bookDao))
            {
                return(bookDao);
            }

            DBWorker dbWorker  = new DBWorker(connectionString);
            var      authorDao = new AuthorDao()
            {
                DBWorker = dbWorker,
            };

            bookDao = new BookDao()
            {
                DBWorker  = dbWorker,
                AuthorDao = authorDao
            };

            authorDao.BookDao = bookDao;

            _bookDaoCache.TryAdd(connectionString, bookDao);
            _authorDaoCache.TryAdd(connectionString, authorDao);

            return(bookDao);
        }
Beispiel #2
0
        public static IAuthorDao GetAuthorDao(string connectionString)
        {
            if (_authorDaoCache.TryGetValue(connectionString, out var authorDao))
            {
                return(authorDao);
            }

            DBWorker dbWorker = new DBWorker(connectionString);

            var bookDao = new BookDao()
            {
                DBWorker = dbWorker
            };

            authorDao = new AuthorDao()
            {
                DBWorker = dbWorker,
                BookDao  = bookDao
            };

            bookDao.AuthorDao = authorDao;

            _authorDaoCache.TryAdd(connectionString, authorDao);
            _bookDaoCache.TryAdd(connectionString, bookDao);
            return(authorDao);
        }