本文整理汇总了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);
}
示例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);
//.........这里部分代码省略.........