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


C# IRepository.Add方法代码示例

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


在下文中一共展示了IRepository.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: InitializeSetting

 private static Setting InitializeSetting(string settingName, IRepository repository)
 {
     var setting = new Setting { Name = settingName.Encrypt() };
     repository.Add<Setting>(setting);
     repository.Save();
     return setting;
 }
开发者ID:Celdorfpwn,项目名称:ASAP,代码行数:7,代码来源:ConfigFactory.cs

示例4: Main

        static void Main(string[] args)
        {
            var builder = new ContainerBuilder();

            builder.RegisterType<Customer>().As<ICustomer>();
            builder.RegisterType<LineItem>().As<ILineItem>();
            builder.RegisterType<Order>().As<IOrder>();
            builder.RegisterType<Product>().As<IProduct>();

            Container = builder.Build();

            _customerRepo = new Repository<Customer>();
            _customerRepo.Add(new Customer { FirstName = "Chris", LastName = "Cais" });
            _customerRepo.Add(new Customer { FirstName = "James", LastName = "Harden" });
            _customerRepo.Save();
        }
开发者ID:ItsDubC,项目名称:OrderDemo1,代码行数:16,代码来源:Program.cs

示例5: PSTutorialFlags

        public PSTutorialFlags(account account, IRepository<character_tutorial> characterTutorials)
            : base(WorldOpcodes.SMSG_TUTORIAL_FLAGS)
        {
            character_tutorial characterTutorial = characterTutorials.SingleOrDefault(ct => ct.account == account.id);

            if (characterTutorial == null)
            {
                characterTutorial = new character_tutorial()
                                        {
                                            account = account.id,
                                            tut0 = 0,
                                            tut1 = 0,
                                            tut2 = 0,
                                            tut3 = 0,
                                            tut4 = 0,
                                            tut5 = 0,
                                            tut6 = 0,
                                            tut7 = 0
                                        };
                characterTutorials.Add(characterTutorial);
            }

            this.Write((byte)characterTutorial.tut0);
            this.Write((byte)characterTutorial.tut1);
            this.Write((byte)characterTutorial.tut2);
            this.Write((byte)characterTutorial.tut3);
            this.Write((byte)characterTutorial.tut4);
            this.Write((byte)characterTutorial.tut5);
            this.Write((byte)characterTutorial.tut6);
            this.Write((byte)characterTutorial.tut7);
        }
开发者ID:Refuge89,项目名称:Vanilla,代码行数:31,代码来源:PSTutorialFlags.cs

示例6: Add

        public void Add(BusinessObjects.GroupRelation entity)
        {
            //Add GroupRelation
            using (_GroupRelationRepository = new GenericRepository<DAL.DataEntities.GroupRelation>())
            {
                _GroupRelationRepository.Add((DAL.DataEntities.GroupRelation)entity.InnerEntity);
                _GroupRelationRepository.SaveChanges();
            }

            //Add GroupRelations_To_Features
            using (_GroupRelationsToFeaturesRepository = new GenericRepository<DAL.DataEntities.GroupRelation_To_Feature>())
            {

                foreach (int childFeatureID in entity.ChildFeatureIDs)
                {
                    DAL.DataEntities.GroupRelation_To_Feature grToFeature = new DAL.DataEntities.GroupRelation_To_Feature();
                    grToFeature.GroupRelationID = entity.ID;
                    grToFeature.ParentFeatureID = entity.ParentFeatureID;
                    grToFeature.ChildFeatureID = childFeatureID;

                    _GroupRelationsToFeaturesRepository.Add(grToFeature);
                }

                _GroupRelationsToFeaturesRepository.SaveChanges();
            }
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:26,代码来源:GroupRelationService.cs

示例7: Add_Should_Result_In_Proper_Total_Items

        public void Add_Should_Result_In_Proper_Total_Items(IRepository<Contact, string> repository)
        {
            repository.Add(new Contact { Name = "Test User" });

            var result = repository.GetAll();
            result.Count().ShouldEqual(1);
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:7,代码来源:RepositoryAddTests.cs

示例8: ExecuteWithData

 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var name = cmd.Split(new[] { ' ' }, 2)[1];
     repo.Add(new GameObject { Name = name, Location = player });
     console.WriteLine("You create a {0}.", name);
     return true;
 }
开发者ID:trayburn,项目名称:Adventure,代码行数:7,代码来源:CreateCommand.cs

示例9: Add

        public void Add(BusinessObjects.FeatureSelection entity)
        {
            using (_FeatureSelectionRepository = new GenericRepository<DAL.DataEntities.FeatureSelection>())
            {
                //Add the FeatureSelection
                _FeatureSelectionRepository.Add((DAL.DataEntities.FeatureSelection)entity.InnerEntity);
                _FeatureSelectionRepository.SaveChanges();

                //Add AttributeValues
                using (_AttributeValuesRepository = new GenericRepository<DAL.DataEntities.AttributeValue>())
                {
                    for (int i = entity.AttributeValues.Count - 1; i >= 0; i--)
                    {
                        BLL.BusinessObjects.AttributeValue BLLAttributeValue = entity.AttributeValues[i];
                        BLLAttributeValue.FeatureSelectionID = entity.ID;

                        //Add
                        if (BLLAttributeValue.ToBeDeleted == false && BLLAttributeValue.ID == 0)
                        {
                            _AttributeValuesRepository.Add((DAL.DataEntities.AttributeValue)BLLAttributeValue.InnerEntity);
                        }
                    }
                    _AttributeValuesRepository.SaveChanges();
                }
            }
        }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:26,代码来源:FeatureSelectionService.cs

示例10: Add

 public void Add(BusinessObjects.Constraint entity)
 {
     using (_ConstraintRepository = new GenericRepository<DAL.DataEntities.Constraint>())
     {
         _ConstraintRepository.Add((DAL.DataEntities.Constraint)entity.InnerEntity);
         _ConstraintRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:8,代码来源:ConstraintService.cs

示例11: Get_With_String_Selector_Should_Return_Item_If_Item_Exists

        public void Get_With_String_Selector_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
        {
            var contact = new Contact { Name = "Test User" };
            repository.Add(contact);

            var result = repository.Get(contact.ContactId, c => c.Name);
            result.ShouldEqual("Test User");
        }
开发者ID:mgmccarthy,项目名称:SharpRepository,代码行数:8,代码来源:RepositoryGetTests.cs

示例12: Add

 public void Add(BLL.BusinessObjects.UITemplate entity)
 {
     using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
     {
         _UITemplateRepository.Add((DAL.DataEntities.UITemplate)entity.InnerEntity);
         _UITemplateRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:8,代码来源:UITemplateService.cs

示例13: RegistrationEvent

        private void RegistrationEvent(IActivityRegister activityRegister, IRepository repository, ActivityTypes activityType)
        {
            if (repository == null)
                throw new ArgumentNullException(nameof(repository));

            var activity = ActivityCreate(activityRegister.ObjectInfo, activityType);
            repository.Add(activity);
        }
开发者ID:dyatlov-a,项目名称:cEditor,代码行数:8,代码来源:UserActivityMonitoring.cs

示例14: Add

 public void Add(BusinessObjects.Model entity)
 {
     using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
     {
         _ModelRepository.Add((DAL.DataEntities.Model)entity.InnerEntity);
         _ModelRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:8,代码来源:ModelService.cs

示例15: Add

 public void Add(BusinessObjects.CustomRule entity)
 {
     using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
     {
         _CustomRuleRepository.Add((DAL.DataEntities.CustomRule)entity.InnerEntity);
         _CustomRuleRepository.SaveChanges();
     }
 }
开发者ID:dswingle,项目名称:openconfigurator,代码行数:8,代码来源:CustomRuleService.cs


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