public bool Delete(DataType entity)
{
Contract.Requires(entity != null);
Contract.Requires(entity.Id >= 0);
using (IUnitOfWork uow = this.GetUnitOfWork())
{
IRepository<DataType> repo = uow.GetRepository<DataType>();
entity = repo.Reload(entity);
// remove all associations
entity.ApplicableUnits.ToList().ForEach(u => u.AssociatedDataTypes.Remove(entity));
entity.ApplicableUnits.Clear();
entity.DataContainers.Clear();
repo.Delete(entity);
uow.Commit();
}
// if any problem was detected during the commit, an exception will be thrown!
return (true);
}