decimal Total { get; private set; } public Order(Guid id, IEnumerable<Product> orderItems) : base(id) { // 針對 Products 檢核(略) // 計算總金額 var total = 0m; foreach (var item in orderItems) { if (item.UnitPrice > 0) { total += item.UnitPrice; } else { throw new ArgumentOutOfRangeException(nameof(item.UnitPrice)); } } Total = total; } }