本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
示例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();
}
}
示例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);
}
示例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;
}
示例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();
}
}
}
示例10: Add
public void Add(BusinessObjects.Constraint entity)
{
using (_ConstraintRepository = new GenericRepository<DAL.DataEntities.Constraint>())
{
_ConstraintRepository.Add((DAL.DataEntities.Constraint)entity.InnerEntity);
_ConstraintRepository.SaveChanges();
}
}
示例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");
}
示例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();
}
}
示例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);
}
示例14: Add
public void Add(BusinessObjects.Model entity)
{
using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
{
_ModelRepository.Add((DAL.DataEntities.Model)entity.InnerEntity);
_ModelRepository.SaveChanges();
}
}
示例15: Add
public void Add(BusinessObjects.CustomRule entity)
{
using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
{
_CustomRuleRepository.Add((DAL.DataEntities.CustomRule)entity.InnerEntity);
_CustomRuleRepository.SaveChanges();
}
}