当前位置: 首页>>代码示例>>C#>>正文


C# Repository.Flush方法代码示例

本文整理汇总了C#中Repository.Flush方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.Flush方法的具体用法?C# Repository.Flush怎么用?C# Repository.Flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Repository的用法示例。


在下文中一共展示了Repository.Flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAccountsByCustomerSomeAccountsFound

        public void GetAccountsByCustomerSomeAccountsFound()
        {
            IAccountRepository accountRepository = new AccountRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer thirdParty1 = new Customer { Code = "tjdsklfs", Email = "[email protected]", LastName = "roux", FirstName = "Olivier", Password = "Pass", PasswordSalt = "sss" };
            Customer thirdParty2 = new Customer { Code = "topsecret", Email = "[email protected]", LastName = "roux2", FirstName = "Olivier", Password = "Pass2", PasswordSalt = "sss" };

            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="12354"};
            Account account2 = new Account { Balance = 202, BalanceDate = DateTime.Now, Number = "dsf2", Iban="12435"};

            Role role = new Role{Id=1};
            thirdParty1.RelatedAccounts.Add(account1, role);
            thirdParty1.RelatedAccounts.Add(account2, role);

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(thirdParty1);
                repository.Save(thirdParty2);
                repository.Save(account1);
                repository.Save(account2);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByCustomer(thirdParty1.Id);
                Assert.AreEqual(2, accounts.Count);
            }
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:28,代码来源:AccountRepositoryTest.cs

示例2: FindIndividualCustomersByName

        public void FindIndividualCustomersByName()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "tjdsklfs", Email = "[email protected]", FirstName = "Sim", LastName = "Lehericey", Password = "Toto", PasswordSalt = "sss" };

            IList<Customer> customers1;
            IList<Customer> customers2;
            IList<Customer> customers3;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                //repository.Save(account1);
                repository.Flush();

                String[] names1 = { customer.FirstName };
                String[] names2 = { customer.LastName };
                String[] names3 = { customer.FirstName, customer.LastName };

                customers1 = customerRepository.FindCustomersByName(names1);
                customers2 = customerRepository.FindCustomersByName(names2);
                customers3 = customerRepository.FindCustomersByName(names3);

                Assert.IsNotNull(customers1);
                Assert.IsNotNull(customers2);
                Assert.IsNotNull(customers3);

            }
            Assert.AreEqual("[email protected]", customers1[0].Email);
            Assert.AreEqual("[email protected]", customers2[0].Email);
            Assert.AreEqual("[email protected]", customers3[0].Email);
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:34,代码来源:CustomerRepositoryTest.cs

示例3: CarAd_mapping_standalonetable

        public void CarAd_mapping_standalonetable()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            IRepository repo = new Repository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                Province p = new Province { Label = "Province Sud" };
                City c = new City { Label = "Nouméa", Province = p, LabelUrlPart = "city" };
                p.AddCity(c);
                repo.Save(p);
                repo.Save(c);

                User u = new User
                {
                    Email = "email",
                    Password = "8"
                };
                repo.Save(u);

                Category cat = new Category
                {
                    Label = "label",
                    LabelUrlPart = "label"
                };
                repo.Save(cat);

                CarAd carAd = new CarAd()
                {
                    Title = "title",
                    Body = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer = true,
                    CreatedBy = u,
                    City = c,
                    Category = cat,
                    Kilometers = 2000,
                    Year = 2013
                };
                repo.Save(carAd);

                Ad ad = new Ad()
                {
                    Title = "title",
                    Body = "bidy",
                    CreationDate = DateTime.Now,
                    IsOffer = true,
                    CreatedBy = u,
                    City = c,
                    Category = cat
                };
                repo.Save(ad);
                repo.Flush();

            }
        }
开发者ID:bea-project,项目名称:bea-web,代码行数:56,代码来源:CarAdMapTest.cs

示例4: Find_NoExpression

        public void Find_NoExpression()
        {
            IClientRepository clientRepository = new ClientRepository(NHibernateHelper.SessionFactory, _accountRepository);
            Repository repository = new Repository(NHibernateHelper.SessionFactory);

            Client client = new Client { LastName = "Aaa", FirstName = "Bbb", StartDate = DateTime.Now };

            using (ITransaction transaction = NHibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(client);
                repository.Flush();

                IList<Client> result = clientRepository.Find(null);
                Assert.AreEqual(1, result.Count);
            }
        }
开发者ID:jbuiss0n,项目名称:Tests_UnitTesting,代码行数:16,代码来源:ClientRepositoryTest.cs

示例5: GetUserByIdentity_Found_NotFound

        public void GetUserByIdentity_Found_NotFound()
        {
            IUserRepository userRepository = new UserRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Id = 1, Identification = "Ident", Email = "Test", Password = "Pass", FirstName = "Name", LastName = "Last", Code = "Code", PasswordSalt = "sss" };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Flush();
                UserIdentity user = userRepository.GetUserByIdentity(customer.Identification);
                UserIdentity user2 = userRepository.GetUserByIdentity("test");
                Assert.AreEqual(user.Email, customer.Email);
                Assert.AreEqual(user2, null);
            }
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:17,代码来源:UserRepositoryTest.cs

示例6: GetAdvisorByIdentity_Found_NotFound

        public void GetAdvisorByIdentity_Found_NotFound()
        {
            IAdvisorRepository advisorRepository = new AdvisorRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Advisor advisor = new Advisor { Email = "[email protected]", FirstName = "Sim", LastName = "Lehericey", Identification="Ident"};

            Advisor retrievedAdvisor;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(advisor);
                repository.Flush();
                retrievedAdvisor = advisorRepository.GetAdvisorByIdentity(advisor.Identification);
            }
            Assert.IsNotNull(retrievedAdvisor);
            Assert.AreEqual(advisor.Email,retrievedAdvisor.Email);
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:18,代码来源:AdvisorRepositoryTest.cs

示例7: GetAccountByCustomerNoAccountFound

        public void GetAccountByCustomerNoAccountFound()
        {
            IAccountRepository accountRepository = new AccountRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer thirdParty1 = new Customer { Code = "tjdsklfs", Email = "[email protected]", LastName = "Roux", FirstName = "Olivier", Password = "Pass1", PasswordSalt = "sss" };
            Customer thirdParty2 = new Customer { Code = "topsecret", Email = "[email protected]", LastName = "Roux2", FirstName = "Olivier", Password = "Pass2", PasswordSalt = "sss" };
            Account account1 = new Account { Balance = 201, BalanceDate = DateTime.Now, Number = "dsf1", Iban="12349340943"};

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(thirdParty1);
                repository.Save(thirdParty2);
                repository.Save(account1);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByCustomer(thirdParty2.Id);
                Assert.AreEqual(0, accounts.Count);
            }
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:21,代码来源:AccountRepositoryTest.cs

示例8: GetTaskForAdvisor_Found

        public void GetTaskForAdvisor_Found()
        {
            ITaskRepository taskRepository = new TaskRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Advisor advisor = new Advisor { Id =1, FirstName="FirstName"};
            Task task = new Task { Id = 1, Advisor = advisor };
            Task task1 = new Task { Id = 2, Advisor = advisor };

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(advisor);
                repository.Save(task);
                repository.Save(task1);

                repository.Flush();

                IList<Task> tasks = taskRepository.GetTasksForAdvisor(advisor.Id);
                Assert.AreEqual(2, tasks.Count);
                Assert.AreEqual(tasks[0].Advisor.FirstName, advisor.FirstName);
            }
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:22,代码来源:TaskRepositoryTest.cs

示例9: GetCustomerByCode_Found_NotFound

        public void GetCustomerByCode_Found_NotFound()
        {
            ICustomerRepository customerRepository = new CustomerRepository(NhibernateHelper.SessionFactory);
            Repository repository = new Repository(NhibernateHelper.SessionFactory);

            Customer customer = new Customer { Code = "someCode", Email = "[email protected]", FirstName = "Sim", LastName = "Lehericey", Password = "Toto", Identification = "Ident", PasswordSalt = "sss" };

            Customer foundCustomer;
            Customer notFoundCustomer;

            using (NhibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(customer);
                repository.Flush();

                foundCustomer = customerRepository.GetCustomerByCode(customer.Code);
                notFoundCustomer = customerRepository.GetCustomerByCode("a");
            }
            Assert.IsNull(notFoundCustomer);
            Assert.IsNotNull(foundCustomer);
            Assert.AreEqual("[email protected]", foundCustomer.Email);
        }
开发者ID:al-main,项目名称:CloudyBank,代码行数:22,代码来源:CustomerRepositoryTest.cs

示例10: GetAccountsByClient_NoAccountFound

        public void GetAccountsByClient_NoAccountFound()
        {
            IOperationRepository operationRepository = new OperationRepository(NHibernateHelper.SessionFactory);
            IAccountRepository accountRepository = new AccountRepository(NHibernateHelper.SessionFactory, operationRepository);
            Repository repository = new Repository(NHibernateHelper.SessionFactory);

            Client client1 = new Client { LastName = "Aaa", FirstName = "Bbb", StartDate = DateTime.Now };
            Client client2 = new Client { LastName = "Ccc", FirstName = "Ddd", StartDate = DateTime.Now };
            Account account1 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };
            Account account2 = new Account { AccountHolder = client1, OpeningDate = DateTime.Now };

            using (ITransaction transaction = NHibernateHelper.SessionFactory.GetCurrentSession().BeginTransaction())
            {
                repository.Save(client1);
                repository.Save(client2);
                repository.Save(account1);

                repository.Flush();

                IList<Account> accounts = accountRepository.GetAccountsByClient(client2.Id);
                Assert.AreEqual(0, accounts.Count);
            }
        }
开发者ID:jbuiss0n,项目名称:Tests_UnitTesting,代码行数:23,代码来源:AccountRepositoryTest.cs

示例11: Invoke

        /// <summary>
        ///  Handle 'around' advice for testing services
        /// </summary>
        public object Invoke(IMethodInvocation invocation)
        {
            object returnValue = null;
            _repository = ServiceTestBase.GetRepository();

            DomainRegistry.Repository = _repository;
            DomainRegistry.Library = null;

            try
            {
                returnValue = invocation.Proceed();

                _repository.Flush();
                _repository.Clear();
            }
            catch (Exception e)
            {
                returnValue = ServiceResult.Error(invocation.Method.ReturnType, e);
            }

            _visitedObjects.Clear();
            VerifyNoRealDomainObjects(returnValue);
            return returnValue;
        }
开发者ID:FlukeFan,项目名称:Atlanta,代码行数:27,代码来源:AopAroundTestAdvice.cs

示例12: AdvancedSearchAds_MotoAds_MotoProperties_ReturnMotoAd


//.........这里部分代码省略.........

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Auto",
                    LabelUrlPart = "Auto"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                CarAd car = new CarAd
                {
                    Id = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u
                };

                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(car);
                repo.Save(a);

                Category cat2 = new Category
                {
                    Label = "Moto",
                    LabelUrlPart = "Moto"
                };

                MotoBrand brand = new MotoBrand
                {
                    Label = "Suzuki"
                };

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat2
                };

                MotoAd moto = new MotoAd
                {
                    Id = 2,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat2,
                    Brand = brand,
                    EngineSize = 650,
                    CreatedBy = u
                };
                repo.Save(brand);
                repo.Save(cat2);
                repo.Save(moto);
                repo.Save(a2);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    AndSearchStrings = new String[] { "aveo" },
                    BrandId = brand.Id,
                    MinEngineSize = 250,
                    MaxEngineSize = 800
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<MotoAd>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a2, result[0]);
            }
        }
开发者ID:bea-project,项目名称:bea-web,代码行数:101,代码来源:SearchRepositoryTest.cs

示例13: AdvancedSearchAds_Ad_MinMaxPrice_ReturnMatchingAds

        public void AdvancedSearchAds_Ad_MinMaxPrice_ReturnMatchingAds()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data
                Province p1 = new Province
                {
                    Label = "p1"
                };

                User u = new User
                {
                    Email = "[email protected]",
                    Password = "hihi"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "city",
                    LabelUrlPart = "city"
                };
                p1.AddCity(c);

                Category cat = new Category
                {
                    Label = "Location",
                    LabelUrlPart = "Location"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                Ad loc = new Ad
                {
                    Id = 1,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Price = 1000
                };

                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(loc);
                repo.Save(a);

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                Ad loc2 = new Ad
                {
                    Id = 2,
                    Title = "chaussure",
                    Body = "boite a chaussure",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    CreatedBy = u,
                    Price = 2000
                };
                repo.Save(loc2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    MinPrice = 0,
                    MaxPrice = 1000
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<Ad>(param);
//.........这里部分代码省略.........
开发者ID:bea-project,项目名称:bea-web,代码行数:101,代码来源:SearchRepositoryTest.cs

示例14: AdvancedSearchAds_CarAds_CarProperties_ReturnCarAd


//.........这里部分代码省略.........
                Category cat = new Category
                {
                    Label = "Auto",
                    LabelUrlPart = "Auto"
                };

                CarFuel fuel = new CarFuel
                {
                    Label = "Diesel"
                };

                VehicleBrand brand = new VehicleBrand
                {
                    Label = "Aveo"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                CarAd car = new CarAd
                {
                    Id = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    Year = 2011,
                    Kilometers = 10000,
                    IsAutomatic = true,
                    Fuel = fuel,
                    Brand = brand,
                    CreatedBy = u
                };

                repo.Save(brand);
                repo.Save(fuel);
                repo.Save(p1);
                repo.Save(c);
                repo.Save(cat);
                repo.Save(u);
                repo.Save(car);
                repo.Save(a);

                SearchAdCache a2 = new SearchAdCache
                {
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };

                CarAd car2 = new CarAd
                {
                    Id = 1,
                    Title = "aveo",
                    Body = "aveo sport 1.2 16s",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat,
                    Year = 2001,
                    Kilometers = 95000,
                    Brand = brand,
                    CreatedBy = u
                };
                repo.Save(car2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                AdSearchParameters param = new AdSearchParameters
                {
                    AndSearchStrings = new String[] { "aveo" },
                    MinKm = 0,
                    MaxKm = 11000,
                    MinYear = 2000,
                    MaxYear = 2012,
                    BrandId = brand.Id,
                    FueldId = fuel.Id,
                    IsAuto = true
                };

                // When
                IList<SearchAdCache> result = adRepo.AdvancedSearchAds<CarAd>(param);

                // Then
                Assert.AreEqual(1, result.Count);
                Assert.AreEqual(a, result[0]);
            }
        }
开发者ID:bea-project,项目名称:bea-web,代码行数:101,代码来源:SearchRepositoryTest.cs

示例15: SearchAds_SearchByTitleAndCategories

        public void SearchAds_SearchByTitleAndCategories()
        {
            ISessionFactory sessionFactory = NhibernateHelper.SessionFactory;
            Repository repo = new Repository(sessionFactory);
            SearchRepository adRepo = new SearchRepository(sessionFactory);

            using (ITransaction transaction = sessionFactory.GetCurrentSession().BeginTransaction())
            {
                // Given
                #region test data

                User u = new User
                {
                    Email = "[email protected]",
                    Password = "hihi"
                };
                repo.Save<User>(u);

                City c = new City
                {
                    Label = "CherzmOi",
                    LabelUrlPart = "city"
                };

                Category cat = new Category
                {
                    Label = "Moto",
                    LabelUrlPart = "Moto"
                };

                SearchAdCache a = new SearchAdCache
                {
                    AdId = 1,
                    Title = "titre 1",
                    Body = "content",
                    City = c,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 18),
                    Category = cat
                };
                repo.Save<City>(c);
                repo.Save<Category>(cat);
                repo.Save(a);

                City c2 = new City
                {
                    Label = "CherzmOi2",
                    LabelUrlPart = "city2"
                };

                Category cat2 = new Category
                {
                    Label = "Auto",
                    LabelUrlPart = "Auto"
                };

                SearchAdCache a2 = new SearchAdCache
                {
                    AdId = 2,
                    Title = "title 2",
                    Body = "content",
                    City = c2,
                    CreationDate = new DateTime(2012, 01, 16, 23, 52, 17),
                    Category = cat2
                };
                repo.Save<City>(c2);
                repo.Save<Category>(cat2);
                repo.Save(a2);

                repo.Flush();

                #endregion

                // When
                IList<SearchAdCache> result = adRepo.SearchAds(andSearchStrings: new String[] { "ti" }, categoryIds: new int[] { cat.Id, cat2.Id });

                // Then
                Assert.AreEqual(2, result.Count);
                Assert.AreEqual(a, result[0]);
                Assert.AreEqual(a2, result[1]);
            }
        }
开发者ID:bea-project,项目名称:bea-web,代码行数:81,代码来源:SearchRepositoryTest.cs


注:本文中的Repository.Flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。