public void RemoveDataView(BExIS.Dlm.Entities.DataStructure.StructuredDataStructure dataStructure, DataView view)
{
Contract.Requires(dataStructure != null && dataStructure.Id >= 0);
Contract.Requires(view != null && view.Id >= 0);
Contract.Requires(view.Dataset == null);
//Contract.Ensures(Contract.Result<StructuredDataStructure>() != null && Contract.Result<StructuredDataStructure>().Id >= 0);
StructuredDataStructureRepo.Reload(dataStructure);
StructuredDataStructureRepo.LoadIfNot(dataStructure.Views);
int count = (from v in dataStructure.Views
where v.Id.Equals(view.Id)
select v
)
.Count();
if (count <= 0)
throw new Exception(string.Format("There is no connection between data structure {0} and view {1}", dataStructure.Id, view.Id));
dataStructure.Views.Remove(view);
view.DataStructures.Remove(dataStructure);
using (IUnitOfWork uow = this.GetUnitOfWork())
{
IRepository<StructuredDataStructure> repo = uow.GetRepository<StructuredDataStructure>();
repo.Put(dataStructure);
uow.Commit();
}
//throw new NotImplementedException();
}