コード例 #1
0
        public DatabaseFixture()
        {
            var options = new DbContextOptionsBuilder <NewsDbContext>()
                          .UseInMemoryDatabase(databaseName: "NewsDB")
                          .Options;

            dbcontext = new NewsDbContext(options);

            dbcontext.Articles.Add(new Article {
                Id = 1, Author = "author1", Comments = "comments1", Content = "content1", Description = "description1", PublishedAt = "11-11-2011", Title = "title1", Url = "url1", UrlToImage = "UrlToImage1"
            });
            dbcontext.Articles.Add(new Article {
                Id = 2, Author = "author2", Comments = "comments2", Content = "content2", Description = "description2", PublishedAt = "11-11-2011", Title = "title2", Url = "url2", UrlToImage = "UrlToImage2"
            });
            dbcontext.Articles.Add(new Article {
                Id = 3, Author = "author3", Comments = "comments3", Content = "content3", Description = "description3", PublishedAt = "11-11-2011", Title = "title13", Url = "url3", UrlToImage = "UrlToImage3"
            });

            dbcontext.SaveChanges();
        }
コード例 #2
0
        public DatabaseFixture()
        {
            var options = new DbContextOptionsBuilder <NewsDbContext>()
                          .UseInMemoryDatabase(databaseName: "NewsDB")
                          .Options;

            dbContext = new NewsDbContext(options);

            dbContext.News.Add(new News {
                Id = 1, Author = "ANI", Title = "news 1 title", Description = "news 1 description", PublishedAt = DateTime.Now, Url = "https://example.com/news1", UrlToImage = "https://example.com/news1image.jpg"
            });
            dbContext.News.Add(new News {
                Id = 2, Author = "TOI", Title = "news 2 title", Description = "news 2 description", PublishedAt = DateTime.Now, Url = "https://example.com/news2", UrlToImage = "https://example.com/news2image.jpg"
            });
            dbContext.News.Add(new News {
                Id = 3, Author = "TheHindu", Title = "news 3 title", Description = "news 3 description", PublishedAt = DateTime.Now, Url = "https://example.com/news3", UrlToImage = "https://example.com/news3image.jpg"
            });
            dbContext.News.Add(new News {
                Id = 4, Author = "MoneyControl", Title = "news 4 title", Description = "news 4 description", PublishedAt = DateTime.Now, Url = "https://example.com/news4", UrlToImage = "https://example.com/news4image.jpg"
            });
            dbContext.SaveChanges();
        }
コード例 #3
0
ファイル: DatabaseFixture.cs プロジェクト: jjaferali/Project2
        public DatabaseFixture()
        {
            var options = new DbContextOptionsBuilder <NewsDbContext>()
                          .UseInMemoryDatabase(databaseName: "NewsDB")
                          .Options;

            dbContext = new NewsDbContext(options);

            dbContext.News.Add(new News {
                NewsId = 1, Author = "Jafer", Title = "Facebook", Category = "Technoloy", Description = "desc", Id = 11, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org"
            });
            dbContext.News.Add(new News {
                NewsId = 2, Author = "Jafer", Title = "WhatsUp", Category = "Technoloy", Description = "desc", Id = 22, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org"
            });
            dbContext.News.Add(new News {
                NewsId = 3, Author = "Jafer", Title = "Twitter", Category = "Technoloy", Description = "desc", Id = 33, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org"
            });
            dbContext.News.Add(new News {
                NewsId = 4, Author = "Jafer", Title = "Ola", Category = "general", Description = "desc", Id = 44, PublishedAt = DateTime.Now, Url = "https://newsdb.org", UrlToImage = "https://newsdb.org"
            });
            dbContext.SaveChanges();
        }
コード例 #4
0
 public NewsRepository(INewsDbContext context)
 {
     _context = context;
 }
コード例 #5
0

        
コード例 #6
0
 public NewsRepository(INewsDbContext dbContext)
 {
     DbContext = dbContext;
 }
コード例 #7
0
 public CachedNewsRepository(INewsDbContext dbContext, INewsCacheService cacheService) : base(dbContext)
 {
     CacheService = cacheService;
 }
コード例 #8
0
ファイル: NewsData.cs プロジェクト: alex687/SoftUni-Homeworks
 public NewsData(INewsDbContext context)
 {
     this.context = context;
     this.repositories = new Dictionary<Type, object>();
 }
コード例 #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewsRepository"/> class.
 /// </summary>
 /// <param name="db">The database.</param>
 public NewsRepository(NewsDbContext db, ServiceProvider provider)
 {
     this.db       = db;
     this.provider = provider;
     db.Database.Migrate();
 }
コード例 #10
0
 public GenericRepository(INewsDbContext context)
 {
     this.context = context;
 }
コード例 #11
0
 public void Dispose()
 {
     NewsList  = null;
     dbContext = null;
 }
コード例 #12
0
ファイル: DatabaseFixture.cs プロジェクト: jjaferali/Project2
 public void Dispose()
 {
     AllNews   = null;
     dbContext = null;
 }
コード例 #13
0
 public void Dispose()
 {
     Articles  = null;
     dbcontext = null;
 }