本文整理汇总了C#中IRepository.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.SaveChanges方法的具体用法?C# IRepository.SaveChanges怎么用?C# IRepository.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
}
示例2: 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();
}
}
}
示例3: DropFileInCategory
private void DropFileInCategory(object sender, DragEventArgs e)
{
ImageService imgService = new ImageService();
string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[];
string fileextension = Path.GetExtension(fileList[0]);
if (fileextension != ".pdf")
{
MessageBox.Show("Not allowed Drag'n'Drop for this file type");
}
else
{
string filename = Path.GetFileNameWithoutExtension(fileList[0]);
string pathtofile = Path.GetFullPath(fileList[0]);
string pathtobookimage = imgService.GenerateImage(pathtofile);
FileInfo fileToAdd = new FileInfo(pathtofile);
int size = (int)fileToAdd.Length;
var book = new Book()
{
Name = filename,
FileType = fileextension,
Path = pathtofile,
PathToBookImg = pathtobookimage,
Author = "Unknown Author",
Size = size
};
Debug.WriteLine(book.Name);
_categoriesRepository = IoCManager.Kernel.Get<IRepository<Category>>();
var concreteCategory = _categoriesRepository.GetByQery(q => q.Name == "Foreign Literature");
concreteCategory.FirstOrDefault().Books.Add(book);
_categoriesRepository.SaveChanges();
MessageBox.Show("Book was added");
}
}
示例4: Add
public void Add(BusinessObjects.CustomRule entity)
{
using (_CustomRuleRepository = new GenericRepository<DAL.DataEntities.CustomRule>())
{
_CustomRuleRepository.Add((DAL.DataEntities.CustomRule)entity.InnerEntity);
_CustomRuleRepository.SaveChanges();
}
}
示例5: Add
public void Add(BusinessObjects.Model entity)
{
using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
{
_ModelRepository.Add((DAL.DataEntities.Model)entity.InnerEntity);
_ModelRepository.SaveChanges();
}
}
示例6: Add
public void Add(BusinessObjects.Constraint entity)
{
using (_ConstraintRepository = new GenericRepository<DAL.DataEntities.Constraint>())
{
_ConstraintRepository.Add((DAL.DataEntities.Constraint)entity.InnerEntity);
_ConstraintRepository.SaveChanges();
}
}
示例7: Add
public void Add(BLL.BusinessObjects.UITemplate entity)
{
using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
{
_UITemplateRepository.Add((DAL.DataEntities.UITemplate)entity.InnerEntity);
_UITemplateRepository.SaveChanges();
}
}
示例8: Add
public void Add(BusinessObjects.Relation entity)
{
using (_RelationRepository = new GenericRepository<DAL.DataEntities.Relation>())
{
_RelationRepository.Add((DAL.DataEntities.Relation)entity.InnerEntity);
_RelationRepository.SaveChanges();
}
}
示例9: Add
public void Add(BusinessObjects.Feature entity)
{
using (_FeatureRepository = new GenericRepository<DAL.DataEntities.Feature>())
{
//Add the Feature
_FeatureRepository.Add((DAL.DataEntities.Feature)entity.InnerEntity);
_FeatureRepository.SaveChanges();
}
}
示例10: Add
public void Add(BusinessObjects.Attribute entity)
{
using (_AttributeRepository = new GenericRepository<DAL.DataEntities.Attribute>())
{
//Add the Attribute
_AttributeRepository.Add((DAL.DataEntities.Attribute)entity.InnerEntity);
_AttributeRepository.SaveChanges();
}
}
示例11: Delete
public void Delete(int id)
{
DAL.DataEntities.Configuration DALConfiguration;
using (_ConfigurationRepository = new GenericRepository<DAL.DataEntities.Configuration>())
{
DALConfiguration = _ConfigurationRepository.SingleOrDefault(m => m.ID == id);
_ConfigurationRepository.Delete(DALConfiguration);
_ConfigurationRepository.SaveChanges();
}
}
示例12: Delete
public void Delete(int id)
{
DAL.DataEntities.Model model;
using (_ModelRepository = new GenericRepository<DAL.DataEntities.Model>())
{
model = _ModelRepository.SingleOrDefault(m => m.ID == id);
_ModelRepository.Delete(model);
_ModelRepository.SaveChanges();
}
}
示例13: Delete
public void Delete(int id)
{
DAL.DataEntities.UITemplate template;
using (_UITemplateRepository = new GenericRepository<DAL.DataEntities.UITemplate>())
{
template = _UITemplateRepository.SingleOrDefault(m => m.ID == id);
_UITemplateRepository.Delete(template);
_UITemplateRepository.SaveChanges();
}
}
示例14: EnsureMember
private static void EnsureMember(IRepository<Member> memberRepository)
{
if (!memberRepository.GetAll().Any(m => m.Name == "Sherlock Holmes"))
{
memberRepository.Add(new Member
{
Name = "Sherlock Holmes"
});
memberRepository.SaveChanges();
}
}
示例15: EnsureProduct
private static void EnsureProduct(Rebate rebate, IRepository<Product> productRepository)
{
if (!productRepository.GetAll().Any(p => p.ProductNumber == 11190))
{
productRepository.Add(new Product
{
ProductNumber = 11190,
Name = "Procrit",
Rebate = rebate
});
productRepository.SaveChanges();
}
}