Exemple #1
0
 public void ImportBooks(EntityApp app, int count = 250)
 {
     _app = app;
       _session = _app.OpenSystemSession();
       //Preload caches
       _bookCache = _session.GetEntities<IBook>(take: 1000).ToDictionary(b => b.Title, StringComparer.InvariantCultureIgnoreCase);
       _publishersCache = _session.GetEntities<IPublisher>(take: 200).ToDictionary(p => p.Name, StringComparer.InvariantCultureIgnoreCase);
       _authorsCache = _session.GetEntities<IAuthor>(take: 1000).ToDictionary(a => a.FirstName + a.LastName, StringComparer.InvariantCultureIgnoreCase);
       _client = new GoogleBooksApiClient();
       var batchSize = count / 5;
       ImportBooksInCategory(BookCategory.Programming, "c#", batchSize);
       ImportBooksInCategory(BookCategory.Programming, "Linux", batchSize);
       ImportBooksInCategory(BookCategory.Fiction, "Comics", batchSize);
       ImportBooksInCategory(BookCategory.Fiction, "Science fiction", batchSize);
       ImportBooksInCategory(BookCategory.Kids, "Fairy tales", batchSize);
 }
Exemple #2
0
        public void ImportBooks(EntityApp app, int count = 250)
        {
            _app     = app;
            _session = _app.OpenSystemSession();
            //Preload caches
            _bookCache       = _session.GetEntities <IBook>(take: 1000).ToDictionary(b => b.Title, StringComparer.OrdinalIgnoreCase);
            _publishersCache = _session.GetEntities <IPublisher>(take: 200).ToDictionary(p => p.Name, StringComparer.OrdinalIgnoreCase);
            _authorsCache    = _session.GetEntities <IAuthor>(take: 1000).ToDictionary(a => a.FirstName + a.LastName, StringComparer.OrdinalIgnoreCase);
            _client          = new GoogleBooksApiClient(_session.Context);
            var batchSize = count / 5;

            ImportBooksInCategory(BookCategory.Programming, "c#", batchSize);
            ImportBooksInCategory(BookCategory.Programming, "Linux", batchSize);
            ImportBooksInCategory(BookCategory.Fiction, "Comics", batchSize);
            ImportBooksInCategory(BookCategory.Fiction, "Science fiction", batchSize);
            ImportBooksInCategory(BookCategory.Kids, "Fairy tales", batchSize);
        }//method