예제 #1
0
        public IActionResult Insert()
        {
            try
            {
                var seed = new Seed();

                var authors = new List <Author>();
                var tags    = new List <Tag>();
                var books   = new List <Book>();

                authors.Populate(seed.Authors, 1000000);
                tags.Populate(seed.Tags, 1000000);

                SwAuthor.Start();
                _authorRepository.Insert(authors);

                SwAuthor.Stop();

                SwTags.Start();
                _tagRepository.Insert(tags);
                SwTags.Stop();

                books.Populate(a => seed.Books(authors, a), 1000000);

                SwBooks.Start();
                _bookRepository.Insert(books);
                SwBooks.Stop();

                SwBookTags.Start();
                books = _bookRepository.Table.ToList();
                tags  = _tagRepository.Table.ToList();
                SwBookTags.Stop();

                var bookTags = new List <BookTag>().Populate(bt => seed.BookTags(books, tags, bt), 1000000);

                bookTags = bookTags.DistinctBy(x => new { x.BookId, x.TagId }).ToList();

                SwBookTags.Start();
                _bookTagRepository.Insert(bookTags);
                SwBookTags.Stop();

                return(Json(new
                {
                    Author = SwAuthor.Elapsed.TotalSeconds,
                    Book = SwBooks.Elapsed.TotalSeconds,
                    tags = SwTags.Elapsed.TotalSeconds,
                    BookTags = SwBookTags.Elapsed.TotalSeconds
                }));
            }
            catch (System.Exception e)
            {
                _logger.Error(methodName: "Insert", message: "Insert failed from EntityFramework", programName: "Logger", runGroup: RunGroupName, keyValue: "125-67-546567-045", exception: e, additionalData: new[] { e.StackTrace, e.Message, e.Source });
                return(Json(new
                {
                }));
            }
        }
예제 #2
0
        public IActionResult Insert()
        {
            try
            {
                var seed = new Seed();

                var authors = new List <Author>().Populate(seed.Authors, EntryLimit);
                var tags    = new List <Tag>().Populate(seed.Tags, EntryLimit);

                SwAuthor.Start();
                _authorRepository.Insert(authors);

                SwAuthor.Stop();

                authors = _authorRepository.GetAll();
                var books = new List <Book>().Populate(a => seed.Books(authors, a), EntryLimit);

                SwTags.Start();
                _tagRepository.Insert(tags);
                SwTags.Stop();

                SwBooks.Start();
                _bookRepository.Insert(books);
                SwBooks.Stop();

                SwBookTags.Start();
                books = _bookRepository.GetAll();
                tags  = _tagRepository.GetAll();
                SwBookTags.Stop();

                var bookTags = new List <BookTag>().Populate(bt => seed.BookTags(books, tags, bt), EntryLimit);

                SwBookTags.Start();
                _bookTagRepository.Insert(bookTags);
                SwBookTags.Stop();

                return(Json(new
                {
                    Author = SwAuthor.Elapsed.TotalSeconds,
                    Book = SwBooks.Elapsed.TotalSeconds,
                    tags = SwTags.Elapsed.TotalSeconds,
                    BookTags = SwBookTags.Elapsed.TotalSeconds
                }));
            }
            catch (System.Exception e)
            {
                var watch = e;
                _logger.Error(methodName: "Insert", message: "Insert failed from Dapper", programName: "Logger", runGroup: RunGroupName, keyValue: "125-67-4567-045", exception: e, additionalData: new [] { e.StackTrace, e.Message, e.Source });
                return(Json(new
                {
                }));
            }
        }