Added container accessor to Castle.Core
[castle.git] / Samples / Castle / PetStore.Model / OrderItem.cs
blobbf610a692aa9466d82704f50c80dfca95c450d9d
1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace PetStore.Model
17 using System;
19 using Castle.ActiveRecord;
22 [ActiveRecord]
23 public class OrderItem : ActiveRecordBase
25 private int id;
26 private Order order;
27 private Product product;
28 private decimal unitPrice;
29 private int quantity;
31 [PrimaryKey]
32 public int Id
34 get { return id; }
35 set { id = value; }
38 [BelongsTo(typeof(Order))]
39 public Order Order
41 get { return order; }
42 set { order = value; }
45 [BelongsTo(typeof(Product))]
46 public Product Product
48 get { return product; }
49 set { product = value; }
52 [Property]
53 public decimal UnitPrice
55 get { return unitPrice; }
56 set { unitPrice = value; }
59 [Property]
60 public int Quantity
62 get { return quantity; }
63 set { quantity = value; }
66 public decimal Total
68 get { return quantity * unitPrice; }