private void FixupInvoice(Invoice previousValue) { if (previousValue != null && previousValue.InvoiceLines.Contains(this)) { previousValue.InvoiceLines.Remove(this); } if (Invoice != null) { if (!Invoice.InvoiceLines.Contains(this)) { Invoice.InvoiceLines.Add(this); } if (InvoiceId != Invoice.InvoiceId) { InvoiceId = Invoice.InvoiceId; } } }