本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}