public void Delete_Loop_With_Cache_And_Ef() { var cachingStrategy = new StandardCachingStrategy <Contact, string>(cacheProvider); var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <TestObjectContextCore>() .UseSqlite(connection) .Options; var context = new TestObjectContextCore(options); context.Database.EnsureCreated(); var repository = new EfCoreRepository <Contact, string>(context, cachingStrategy); repository.Add(new Contact() { ContactId = "1", Name = "Contact1", ContactTypeId = 1 }); repository.Add(new Contact() { ContactId = "2", Name = "Contact2", ContactTypeId = 2 }); repository.Add(new Contact() { ContactId = "3", Name = "Contact3", ContactTypeId = 2 }); repository.FindAll(x => x.ContactTypeId == 2); repository = new EfCoreRepository <Contact, string>(new TestObjectContextCore(options), cachingStrategy); repository.Delete(x => x.ContactTypeId == 2); }
public void Delete_With_Cache_And_Ef() { var cachingStrategy = new StandardCachingStrategy <Contact, string>(cacheProvider); var connection = new SqliteConnection("DataSource=:memory:"); connection.Open(); var options = new DbContextOptionsBuilder <TestObjectContextCore>() .UseSqlite(connection) .Options; var context = new TestObjectContextCore(options); context.Database.EnsureCreated(); var repository = new EfCoreRepository <Contact, string>(context, cachingStrategy); repository.Add(new Contact() { ContactId = "1", Name = "Contact1" }); repository = new EfCoreRepository <Contact, string>(context, cachingStrategy); repository.Get("1"); repository.CacheUsed.ShouldBeTrue(); repository.Delete("1"); }