Example #1
0
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, IEnumerable <Game> values)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "GamesDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                foreach (Game game in values)
                {
                    context.Games.Add(game);
                }

                for (int i = 0; i < 10; ++i)
                {
                    context.Developers.Add(new Developer()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                    context.Publishers.Add(new Publisher()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                }

                context.SaveChanges();
            }
        }
Example #2
0
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "GamesDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                context.Games.Add(new Game
                {
                    Name             = "BBB",
                    ID               = 2,
                    Description      = "DdD",
                    AnnouncementDate = DateTime.Parse("13-09-2019"),
                    ReleaseDate      = DateTime.Parse("13-09-2019"),
                    DeveloperId      = 2,
                    PublisherId      = 3,
                    GameGenres       = new List <GameGenre>(),
                    GamePlatforms    = new List <GamePlatform>()
                });
                context.Games.Add(new Game {
                    Name             = "ZZZ",
                    ID               = 3,
                    Description      = "OOo",
                    AnnouncementDate = DateTime.Parse("15-11-2017"),
                    ReleaseDate      = DateTime.Parse("03-03-2021"),
                    DeveloperId      = 4,
                    PublisherId      = 5,
                    GameGenres       = new List <GameGenre>(),
                    GamePlatforms    = new List <GamePlatform>()
                });
                context.Games.Add(new Game {
                    Name             = "AAA",
                    ID               = 4,
                    Description      = "-><",
                    AnnouncementDate = DateTime.Parse("01-01-2018"),
                    ReleaseDate      = DateTime.Parse("24-12-2022"),
                    DeveloperId      = 6,
                    PublisherId      = 7,
                    GameGenres       = new List <GameGenre>(),
                    GamePlatforms    = new List <GamePlatform>()
                });

                for (int i = 0; i < 10; ++i)
                {
                    context.Developers.Add(new Developer()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                    context.Publishers.Add(new Publisher()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                }
                context.SaveChanges();
            }
        }
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, IEnumerable <Review> values)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "ReviewsDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                foreach (Review review in values)
                {
                    context.Reviews.Add(review);
                }

                for (int i = 0; i < 15; ++i)
                {
                    context.Users.Add(new User()
                    {
                        Name = i.ToString(), RegistrationDate = DateTime.Now.AddDays(i)
                    });
                    context.Languages.Add(new Language()
                    {
                        Name = i.ToString()
                    });

                    context.Developers.Add(new Developer()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                    context.Publishers.Add(new Publisher()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                }

                for (int i = 0; i < 10; ++i)
                {
                    context.Games.Add(new Game
                    {
                        Name             = "BBB" + i,
                        ID               = 1 + i,
                        Description      = "DdD" + i,
                        AnnouncementDate = DateTime.Parse("13-09-2019").AddDays(i),
                        ReleaseDate      = DateTime.Parse("13-09-2019").AddDays(i),
                        DeveloperId      = 2 + i,
                        PublisherId      = 3 + i,
                        GameGenres       = new List <GameGenre>(),
                        GamePlatforms    = new List <GamePlatform>()
                    });
                }

                context.SaveChanges();
            }
        }
Example #4
0
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options, IEnumerable <Genre> values)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "GenresDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                foreach (Genre genre in values)
                {
                    context.Genres.Add(genre);
                }

                context.SaveChanges();
            }
        }
Example #5
0
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "GenresDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                context.Genres.Add(new Genre {
                    Name = "BBB", ID = 2, GameGenres = new List <GameGenre>()
                });
                context.Genres.Add(new Genre {
                    Name = "ZZZ", ID = 3, GameGenres = new List <GameGenre>()
                });
                context.Genres.Add(new Genre {
                    Name = "AAA", ID = 4, GameGenres = new List <GameGenre>()
                });
                context.SaveChanges();
            }
        }
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "PublishersDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                context.Publishers.Add(new Publisher {
                    Name = "BBB", ID = 2, Website = "DdD"
                });
                context.Publishers.Add(new Publisher {
                    Name = "ZZZ", ID = 3, Website = "OOo"
                });
                context.Publishers.Add(new Publisher {
                    Name = "AAA", ID = 4, Website = "-><"
                });
                context.SaveChanges();
            }
        }
Example #7
0
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "UsersDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                context.Users.Add(new User {
                    Name = "BBB", ID = 2, RegistrationDate = DateTime.Parse("04-03-2017")
                });
                context.Users.Add(new User {
                    Name = "ZZZ", ID = 3, RegistrationDate = DateTime.Parse("28-02-2015")
                });
                context.Users.Add(new User {
                    Name = "AAA", ID = 4, RegistrationDate = DateTime.Parse("13-07-2001")
                });
                context.SaveChanges();
            }
        }
        private void InitializeInmemoryDatabase(out DbContextOptions <GameReviewsContext> options)
        {
            options = new DbContextOptionsBuilder <GameReviewsContext>()
                      .UseInMemoryDatabase(databaseName: "ReviewsDatabase" + InMemoryDbIndex++)
                      .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new GameReviewsContext(options))
            {
                context.Reviews.Add(new Review
                {
                    Name        = "BBB",
                    ID          = 2,
                    Text        = "DdD",
                    IsRecommend = true,
                    GameId      = 1,
                    UserId      = 2,
                    LanguageId  = 3
                });
                context.Reviews.Add(new Review
                {
                    Name        = "ZZZ",
                    ID          = 3,
                    Text        = "OOo",
                    IsRecommend = false,
                    GameId      = 2,
                    UserId      = 1,
                    LanguageId  = 3
                });
                context.Reviews.Add(new Review
                {
                    Name        = "AAA",
                    ID          = 4,
                    Text        = "-><",
                    IsRecommend = false,
                    GameId      = 3,
                    UserId      = 1,
                    LanguageId  = 4
                });

                for (int i = 0; i < 15; ++i)
                {
                    context.Users.Add(new User()
                    {
                        Name = i.ToString(), RegistrationDate = DateTime.Now.AddDays(i)
                    });
                    context.Languages.Add(new Language()
                    {
                        Name = i.ToString()
                    });

                    context.Developers.Add(new Developer()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                    context.Publishers.Add(new Publisher()
                    {
                        Name = i.ToString(), Website = "Website" + i
                    });
                }

                for (int i = 0; i < 10; ++i)
                {
                    context.Games.Add(new Game
                    {
                        Name             = "BBB" + i,
                        ID               = 1 + i,
                        Description      = "DdD" + i,
                        AnnouncementDate = DateTime.Parse("13-09-2019").AddDays(i),
                        ReleaseDate      = DateTime.Parse("13-09-2019").AddDays(i),
                        DeveloperId      = 2 + i,
                        PublisherId      = 3 + i,
                        GameGenres       = new List <GameGenre>(),
                        GamePlatforms    = new List <GamePlatform>()
                    });
                }
                context.SaveChanges();
            }
        }