public void DelChild(string id) { IEnumerable <BE.Contract> contract = dimp.SearchContract(x => x.ChildID == id); if (contract != null) { throw new Exception("canot delete this child you have to remove this contract :" + contract.Last().ContractCode); } dimp.DelChild(dimp.SearchChild(x => x.ChildId == id).Last()); }