order total: TotalInCents on both Orders, mapped into OrderDto and OrderData
yak: ordertotalincents-on-both-sides-dto-mapping-j00p
This commit is contained in:
@@ -18,10 +18,10 @@ DbBase.Context = ctx;
|
||||
var jane = new Client { Name = "Jane Doe" };
|
||||
var bob = new Client { Name = "Bob Smith" };
|
||||
|
||||
jane.Orders.Add(new Order { Description = "Design consultation" });
|
||||
jane.Orders.Add(new Order { Description = "Website redesign" });
|
||||
jane.Orders.Add(new Order { Description = "Design consultation", TotalInCents = 120_00 });
|
||||
jane.Orders.Add(new Order { Description = "Website redesign", TotalInCents = 750_00 });
|
||||
|
||||
bob.Orders.Add(new Order { Description = "Monthly retainer" });
|
||||
bob.Orders.Add(new Order { Description = "Monthly retainer", TotalInCents = 85_00 });
|
||||
|
||||
// Orders need to be attached too so they get IDs:
|
||||
ctx.Attach(jane.Orders[0]);
|
||||
@@ -38,7 +38,7 @@ foreach (var client in DbBase.Context!.Tracked.OfType<Client>())
|
||||
{
|
||||
Console.WriteLine($"{client.Name} [{client.Id}]");
|
||||
foreach (var order in client.Orders)
|
||||
Console.WriteLine($" - order [{order.Id}]: {order.Description}");
|
||||
Console.WriteLine($" - order [{order.Id}]: {order.Description} ({order.TotalInCents} cents)");
|
||||
}
|
||||
|
||||
// ----- find by name -------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user