public Boolean DeleteListino(Listino listino) { Listino newListino = GetListino(listino.Id); if (newListino != null) { /// FIRST remove related entries in dettaglioListino DettaglioListinoService dlSrv = new DettaglioListinoService(); List <DettaglioListino> dettagli = dlSrv.GetDettagliByListino(listino.Id); foreach (var dettaglio in dettagli) { context.DettaglioListinoSet.Remove(dettaglio); context.SaveChanges(); } context.ListinoSet.Remove(listino); context.SaveChanges(); return(true); } else { return(false); } }