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


C# Repository.AddNew方法代码示例

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


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

示例1: using

 public int 菜品信息_AddNew(菜品信息EditModel model)
 {
     int _count = 0;
     using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
     {
         using (var context = new BDKRContext())
         {
             var r = new Repository<货品信息>(context);
             var e = r.GetSingle(t => t.编码 == model.编码);
             if (null != e)
                 throw new Exception("菜品信息当前已存在");
             e = new 货品信息
             {
                 单位 = model.单位,
                 名称 = model.菜品名称,
                 备注 = model.附加说明,
                 拼音 = UtilHelper.PinYin(model.菜品名称),
                 是否菜品 = true,
                 编码 = model.编码,
                 规格 = model.规格,
                 货品类别编码 = model.菜品类别
             };
             if (model.当前销售价格 > 0)
             {
                 var cj = new 销售价格表
                 {
                     价格 = model.当前销售价格,
                     创建时间 = DateTime.Now,
                     编码 = 销售价格_GetNewCode(),
                     货品信息编码 = model.编码,
                     附加说明 = ""
                 };
                 var _jg = new Repository<销售价格表>(context);
                 _jg.AddNew(cj);
             }
             _count = r.AddNew(e);
             if (model.Details != null && model.Details.Count > 0)
             {
                 var _bcode = 货品BOM_GetNewCode();
             }
         }
         ts.Complete();
     }
     return _count;
 }
开发者ID:FicerLee,项目名称:BDKR,代码行数:45,代码来源:BDKRWS.svc.cs

示例2: AddHouseholdToRepositories

 private int AddHouseholdToRepositories(Household household, Repository<Household> householdRepository, Repository<Family> familyRepository, Repository<Person> personRepo)
 {
     int persons = 0;
     foreach (var family in household.Families)
     {
         foreach (var person in family.Persons)
         {
             personRepo.AddNew(person);
             persons++;
         }
         familyRepository.AddNew(family);
     }
     householdRepository.AddNew(household);
     return persons;
 }
开发者ID:TravelModellingGroup,项目名称:ILUTE,代码行数:15,代码来源:Immigration.cs

示例3: Divorse

 public void Divorse(Repository<Family> familyRepo)
 {
     var female = FemaleHead;
     var male = MaleHead;
     // no longer married
     MarriageDate = new Date();
     MaleHead = null;
     // add the people to
     female.ExSpouses.Add(male);
     male.ExSpouses.Add(female);
     // unlink the persons
     female.Spouse = null;
     male.Spouse = null;
     female.MaritalStatus = MaritalStatus.Divorced;
     male.MaritalStatus = MaritalStatus.Divorced;
     // create the male's new family object
     male.Family.RemovePerson(male);
     male.Family = new Family() { Household = Household, MaleHead = male, FemaleHead = null };
     male.Family.Persons.Add(male);
     // add the family to the repository
     familyRepo.AddNew(male.Family);
     // and add them into the household as a separate unit
     Household?.Families.Add(male.Family);
 }
开发者ID:TravelModellingGroup,项目名称:ILUTE,代码行数:24,代码来源:Family.cs

示例4: AddMotherAndBabyToNewFamily

 private static void AddMotherAndBabyToNewFamily(Repository<Family> families, Person mother, Person baby, Family originalFamily)
 {
     // Baby family is setup later to reflect the mother's family
     Family newFamily = new Family();
     newFamily.Persons.Add(mother);
     newFamily.Persons.Add(baby);
     var household = originalFamily.Household;
     household?.Families.Add(newFamily);
     newFamily.Household = household;
     originalFamily.Persons.Remove(mother);
     mother.Family = newFamily;
     baby.Family = newFamily;
     newFamily.FemaleHead = mother;
     families.AddNew(newFamily);
 }
开发者ID:TravelModellingGroup,项目名称:ILUTE,代码行数:15,代码来源:BirthModel.cs


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