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


C# IRepository.Persist方法代码示例

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


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

示例1: Before_all_specs

        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            IConfiguration configuration = new BasicConfiguration();
            var container = configuration.Container;

            _ingredientRepository = new IngredientRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());

            _ingredientAdviceRepository = new Repository<IngredientAdvice>(GetNewDataContext());
            _ingredientAdviceDomainService = new IngredientAdviceDomainService(_ingredientRepository,
                                                                               _ingredientAdviceRepository,
                                                                               GetNewDataContext());

           

            _mentor = MentorBuilder.BuildMentor();
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = SemaphoreBuilder.BuildRedSemaphore();
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore();
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            _ingredient = IngredientBuilder.BuildIngredient();
            _ingredientRepository.Add(_ingredient);
            _ingredientRepository.Persist();

            base.Before_each_spec();
        }
开发者ID:consumentor,项目名称:Server,代码行数:34,代码来源:IngredientAdviceDomainServiceSpec.cs

示例2: Before_all_specs

        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);
            

            var ingredient1 = new Ingredient {IngredientName = "Hop", LastUpdated = DateTime.Now};
            var ingredient2 = new Ingredient {IngredientName = "Malt", LastUpdated = DateTime.Now};
            var ingredient3 = new Ingredient {IngredientName = "Water", LastUpdated = DateTime.Now };

            _ingredientRepository = new Repository<Ingredient>(GetNewDataContext());
            _ingredientRepository.Add(ingredient1);
            _ingredientRepository.Add(ingredient2);
            _ingredientRepository.Add(ingredient3);
            _ingredientRepository.Persist();

            _product = ProductBuilder.BuildProduct();
            _product.AddIngredient(ingredient1);
            _product.AddIngredient(ingredient2);
            _product.AddIngredient(ingredient3);
            _productRepository = new Repository<Product>(GetNewDataContext());
            _productRepository.Add(_product);
            _productRepository.Persist();

            base.Before_each_spec();
        }
开发者ID:consumentor,项目名称:Server,代码行数:25,代码来源:ProductIngredientsSpec.cs

示例3: Before_all_specs

        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);
            _productBuilder = new ProductBuilder();

            _productAdviceRepository = new Repository<ProductAdvice>(GetNewDataContext());
            _productAdviceDomainService =
                new ProductAdviceDomainService(new ProductRepository(GetNewDataContext()),
                                                   _productAdviceRepository, GetNewDataContext());

            _productRepository = new ProductRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());     

            _mentor = new Mentor
                          {
                MentorName = "Consumentor"
            };
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = new Semaphore
                             {
                ColorName = "Red",
                Value = -1
            };
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = new Semaphore
                                  {
                                      ColorName = "Green",
                                      Value = 1
                                  };
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            _product = ProductBuilder.BuildProduct();
            _productRepository.Add(_product);
            _productRepository.Persist();

            base.Before_each_spec();
        }
开发者ID:consumentor,项目名称:Server,代码行数:41,代码来源:ProductAdviceDomainServiceSpec.cs

示例4: Before_all_specs

        protected override void Before_all_specs()
        {
            SetupDatabase(ShopGunSpecBase.Database.ShopGun, typeof(Base).Assembly);

            _ingredientAdviceRepository = new Repository<IngredientAdvice>(GetNewDataContext());

            _ingredientRepository = new IngredientRepository(GetNewDataContext());
            _semaphoreRepository = new Repository<Semaphore>(GetNewDataContext());
            _mentorRepository = new Repository<Mentor>(GetNewDataContext());

            _mentor = MentorBuilder.BuildMentor();
            _mentorRepository.Add(_mentor);
            _mentorRepository.Persist();

            _redSemaphore = SemaphoreBuilder.BuildRedSemaphore();
            _semaphoreRepository.Add(_redSemaphore);
            _greenSemaphore = SemaphoreBuilder.BuildGreenSemaphore();
            _semaphoreRepository.Add(_greenSemaphore);
            _semaphoreRepository.Persist();

            base.Before_each_spec();
        }
开发者ID:consumentor,项目名称:Server,代码行数:22,代码来源:IngredientSpec.cs

示例5: PushModule

        public PushModule(IRepository repository)
        {
            _log = LogManager.GetLogger(GetType());
            _log.Info("In Fake Push API....");

            this.RequiresAuthentication();

            Get["api/push"] = _ => Response.AsJson(new {Hello = "welcome to receiving stuff pushed from all over..."});

            Get["api/push/received/all"] = _ =>
            {
                var transations = repository.GetAll<Transaction>().ToList();
                var model = transations.Any()
                    ? transations.Select(
                        s =>
                            new TransactionDto(s.PackageId, s.UserId, s.Username, s.ContractId, s.AccountNumber, s.ResponseDate, s.RequestId, s.Report,
                                s.HasResponse)).OrderByDescending(o => o.ResponseDate).ToList()
                    : new List<TransactionDto>();
                return View["Push/Received", model];
            };

            Get["api/push/received/errors"] = _ =>
            {
                var errors = repository.GetAll<Error>().ToList();
                var model = errors.Any() ? errors.ToList() : new List<Error>();
                return View["Push/Errors", model];
            };

            Post["api/push"] = _ =>
            {
                _log.Info("Importing push item from POST");

                try
                {
                    var model = this.Bind<Transaction>();

                    if (model == null)
                    {
                        _log.Error("Could not bind to package transaction recived from push");
                        repository.Persist(new Error(Guid.NewGuid(), "Could not bind to package transactions received from push", "Receive Pushed Item", DateTime.Now));
                        return HttpStatusCode.BadRequest;
                    }

                    repository.Persist(model);
                }
                catch (Exception ex)
                {
                    repository.Persist(new Error(Guid.NewGuid(), ex.Message, "Receive Pushed Item", DateTime.Now));
                    return HttpStatusCode.BadRequest;
                }
               

                return HttpStatusCode.OK;
            };

            Put["api/push"] = _ =>
            {
                _log.Info("Importing push item from PUT");
                return HttpStatusCode.OK;
            };
        }
开发者ID:rjonker1,项目名称:lightstone-data-platform,代码行数:61,代码来源:PushModule.cs


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