예제 #1
0
        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);
        }
예제 #2
0
        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");
        }
예제 #3
0
        public void Delete_Loop_With_Cache_And_Ef()
        {
            var cachingStrategy = new StandardCachingStrategy <Contact, string>();
            var dbPath          = EfDataDirectoryFactory.Build();

            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");

            var repository = new EfRepository <Contact, string>(new TestObjectEntities("Data Source=" + dbPath), 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 EfRepository <Contact, string>(new TestObjectEntities("Data Source=" + dbPath), cachingStrategy);

            repository.Delete(x => x.ContactTypeId == 2);
        }
        public void Delete_With_Cache_And_Ef()
        {
            var cachingStrategy = new StandardCachingStrategy<Contact, string>();
            var dbPath = EfDataDirectoryFactory.Build();
            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");

            var repository = new EfRepository<Contact, string>(new TestObjectEntities("Data Source=" + dbPath), cachingStrategy);

            repository.Add(new Contact() { ContactId = "1", Name = "Contact1"});

            repository = new EfRepository<Contact, string>(new TestObjectEntities("Data Source=" + dbPath), cachingStrategy);
            repository.Get("1");
            repository.CacheUsed.ShouldBeTrue();
            repository.Delete("1");
        }
        public void Delete_With_Cache_And_Ef()
        {
            var cachingStrategy = new StandardCachingStrategy <Contact, string>();
            var dbPath          = EfDataDirectoryFactory.Build();

            var repository = new EfRepository <Contact, string>(new TestObjectEntities("Data Source=" + dbPath), cachingStrategy);

            repository.Add(new Contact()
            {
                ContactId = "1", Name = "Contact1"
            });

            repository = new EfRepository <Contact, string>(new TestObjectEntities("Data Source=" + dbPath), cachingStrategy);
            repository.Get("1");
            repository.CacheUsed.ShouldBeTrue();
            repository.Delete("1");
        }
        public void Delete_Loop_With_Cache_And_Ef()
        {
            var cachingStrategy = new StandardCachingStrategy<Contact, string>();
            var dbPath = EfDataDirectoryFactory.Build();
            Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");

            var repository = new EfRepository<Contact, string>(new TestObjectEntities("Data Source=" + dbPath), 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 EfRepository<Contact, string>(new TestObjectEntities("Data Source=" + dbPath), cachingStrategy);

            repository.Delete(x => x.ContactTypeId == 2);
        }