Hello,
Please could someone help me with the syntax to add orderlines to an order in the below? I just cant figure out the syntax for it.
many thanks
using System;
using System.Collections.Generic;
namespace ParentChild
{
class Program
{
static void Main(string[] args)
{
var Order = new Order { Id = 1,
Description = "My First Order",
OrderDate = DateTime.Now,
OrderLines.Add(new OrderLine { OrderId =1, Quantity = 100}) //**How do i add orderlines here?**
};
}
}
public class Order
{
public Order()
{
OrderLines = new List<OrderLine>();
}
public int Id { get; set; }
public DateTime OrderDate { get; set; }
public string Description { get; set; }
public virtual List<OrderLine> OrderLines { get; set; }
}
public class OrderLine
{
public int OrderId { get; set; }
public int Quantity { get; set; }
public virtual Order Order { get; set; }
}
}