Skip to content

Composition

Leonardo Porro edited this page Dec 16, 2022 · 1 revision

It's a relationship where a child cannot exist without the parent.

public class Invoice
{
   public Guid Id { get;set; }

   public DateTime DateTime { get; set; }

   [Composition]
   public List<InvoiceRow> Rows { get; set; }
}

public class InvoiceRow
{
   public Guid Id { get; set; }
   
   public string Description { get; set; }

   public double Quantity { get; set; }
   
   public double PricePerUnit { get; set; }
}