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


C# RepositoryFactory.CreateRepository方法代码示例

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


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

示例1: Update

        public void Update(string seasonId)
        {
            var repositoryFactory = new RepositoryFactory();

             SeasonStatistics seasonStatistics;
             using (var seasonStatisticsRepository = repositoryFactory.CreateRepository<SeasonStatistics>())
             {
             seasonStatistics = seasonStatisticsRepository.Find(x => x.SeasonId == seasonId).First();
             }

             // Determine national cup winner.
             using (var matchRepository = repositoryFactory.CreateMatchRepository())
             {
            var cupFinal = matchRepository.GetNationalCupFinal(seasonId);
            seasonStatistics.CupWinner = cupFinal.GetWinner();
            seasonStatistics.CupRunnerUp = cupFinal.HomeTeam.Equals(seasonStatistics.CupWinner) ? cupFinal.HomeTeam : cupFinal.AwayTeam;
             }

             //TODO update more statistics

             _repository.RegisterUpdate(seasonStatistics);
        }
开发者ID:bouwe77,项目名称:fmg,代码行数:22,代码来源:SeasonStatisticsManager.cs

示例2: SynchronizeTest

        public void SynchronizeTest()
        {
            var webServer = new WebServer("http://mss.alkotorg.com", "manager", "423200");
            const int bathSize = 300;
            var storageManager = new SqLiteStorageManager();
            var unitOfWorkFactory = new SqLiteUnitOfWorkFactory(storageManager);

            // Initialization
            const string dbScriptFileName = @"\schema.sql";
            string databaseScriptFullPath = TestEnvironment.GetApplicationDirectory() + dbScriptFileName;
            string databaseFileFullPath = TestEnvironment.GetApplicationDirectory() + @"\storage.sqlite";
            var database = storageManager.CreateOrOpenStorage(databaseFileFullPath, databaseScriptFullPath);

            var repositoryFactory = new RepositoryFactory(storageManager);
            repositoryFactory.RegisterSpecificationTranslator(new CommonTranslator<Customer>())
                             .RegisterSpecificationTranslator(new ShippingAddressSpecTranslator())
                             .RegisterSpecificationTranslator(new CommonTranslator<Category>())
                             .RegisterSpecificationTranslator(new CommonTranslator<PriceList>())
                             .RegisterSpecificationTranslator(new CommonTranslator<Product>())
                             .RegisterSpecificationTranslator(new OrderSpecTranslator())
                             .RegisterSpecificationTranslator(new OrderItemSpecTranslator())
                             .RegisterSpecificationTranslator(new ProductPriceSpecTranslator())
                             .RegisterSpecificationTranslator(
                                 new ProductsUnitOfMeasureSpecTranslator())
                             .RegisterSpecificationTranslator(new RoutePointSpecTranslator())
                             .RegisterSpecificationTranslator(new RouteSpecTranslator())
                             .RegisterSpecificationTranslator(
                                 new RoutePointTemplateSpecTranslator())
                             .RegisterSpecificationTranslator(new RouteTemplateSpecTranslator())
                             .RegisterSpecificationTranslator(new CommonTranslator<Status>())
                             .RegisterSpecificationTranslator(new CommonTranslator<UnitOfMeasure>())
                             .RegisterSpecificationTranslator(new CommonTranslator<Warehouse>());

                // Customers synchronization
                var customerDtoRepository = new WebRepository<CustomerDto>(webServer);
                var customerSqLiteRepository = repositoryFactory.CreateRepository<Customer>();
                DtoTranslator<Customer, CustomerDto> customerTranslator =
                    new CustomerTranslator(repositoryFactory);

                var customerSyncCmd =
                    new SynchronizationCommand<CustomerDto, Customer>(customerDtoRepository,
                                                                      customerSqLiteRepository,
                                                                      customerTranslator, unitOfWorkFactory,
                                                                      bathSize);

                customerSyncCmd.Execute();

                // Shipping addresses synchronization
                var shippingAddressDtoRepository =
                    new WebRepository<ShippingAddressDto>(webServer);
                var shippingAddressSqLiteRepository = repositoryFactory.CreateRepository<ShippingAddress>();
                DtoTranslator<ShippingAddress, ShippingAddressDto> shippingAddressdTranslator =
                    new ShippingAddressdTranslator();

                var shippingAddressSyncCmd =
                    new SynchronizationCommand<ShippingAddressDto, ShippingAddress>(
                        shippingAddressDtoRepository, shippingAddressSqLiteRepository,
                        shippingAddressdTranslator, unitOfWorkFactory, bathSize);
                shippingAddressSyncCmd.Execute();

                // Categories synchronization
                var categoriesDtoRepository = new WebRepository<CategoryDto>(webServer);
                var categorySqLiteRepository = repositoryFactory.CreateRepository<Category>();
                DtoTranslator<Category, CategoryDto> categoriesTranslator = new CategoryTranslator();
                var categoriesSyncCmd = new CategotiesSynchronization(categoriesDtoRepository,
                                                                      categorySqLiteRepository,
                                                                      categoriesTranslator,
                                                                      unitOfWorkFactory, bathSize);

                categoriesSyncCmd.Execute();

                // Statuses synchronization
                var statusDtoRepository = new WebRepository<StatusDto>(webServer);
                var statusSqLiteRepository = repositoryFactory.CreateRepository<Status>();
                DtoTranslator<Status, StatusDto> statusTranslator = new StatusTranslator();

                var statusSyncCommand =
                    new SynchronizationCommand<StatusDto, Status>(statusDtoRepository,
                                                                  statusSqLiteRepository,
                                                                  statusTranslator, unitOfWorkFactory,
                                                                  bathSize);

                statusSyncCommand.Execute();

                // Warehouses synchronization
                var warehouseDtoRepository = new WebRepository<WarehouseDto>(webServer);
                var warehouseSqLiteRepository = repositoryFactory.CreateRepository<Warehouse>();
                DtoTranslator<Warehouse, WarehouseDto> warehouseTranslator =
                    new WarehouseTranslator();

                var warehouseSyncCommand =
                    new SynchronizationCommand<WarehouseDto, Warehouse>(warehouseDtoRepository,
                                                                        warehouseSqLiteRepository,
                                                                        warehouseTranslator,
                                                                        unitOfWorkFactory, bathSize);

                warehouseSyncCommand.Execute();

                // Price lists synchronization
                var priceListDtoRepository = new WebRepository<PriceListDto>(webServer);
//.........这里部分代码省略.........
开发者ID:galievruslan,项目名称:mss-mobile,代码行数:101,代码来源:SynchronizationCommandTest.cs


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