public bool Delete(IEnumerable<ResearchPlan> entities)
{
Contract.Requires(entities != null);
Contract.Requires(Contract.ForAll(entities, (ResearchPlan e) => e != null));
Contract.Requires(Contract.ForAll(entities, (ResearchPlan e) => e.Id >= 0));
using (IUnitOfWork uow = this.GetUnitOfWork())
{
IRepository<ResearchPlan> repo = uow.GetRepository<ResearchPlan>();
foreach (var entity in entities)
{
var latest = repo.Reload(entity);
// remove all associations between current unit and the conversions
latest.Datasets.ToList().ForEach(a => a.ResearchPlan = null);
//delete the entity
repo.Delete(latest);
}
// commit changes
uow.Commit();
}
return (true);
}