fixing missing reference
[castle.git] / Samples / ActiveRecord / MoreComplexSample / Order.cs
blob9cf352c219d75c0345002652e75d35ede88ca500
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 MoreComplexSample
17 using System;
18 using Castle.ActiveRecord;
19 using Iesi.Collections.Generic;
21 public enum OrderStatus : short
23 Created,
24 Cancelled,
25 Processed,
26 Dispatched
29 [ActiveRecord("`Order`")]
30 public class Order : ActiveRecordBase
32 private int id;
33 private DateTime createdAt;
34 private DateTime? dispatchedAt;
35 private Customer customer;
36 private OrderStatus status;
37 private float total;
38 private ISet<Product> products = new HashedSet<Product>();
40 public Order()
42 createdAt = DateTime.Now;
45 [PrimaryKey(PrimaryKeyType.Native)]
46 public int Id
48 get { return id; }
49 set { id = value; }
52 [Property(Update=false)]
53 public DateTime CreatedAt
55 get { return createdAt; }
56 set { createdAt = value; }
59 [Property(Insert=false)]
60 public DateTime? DispatchedAt
62 get { return dispatchedAt; }
63 set { dispatchedAt = value; }
66 [BelongsTo("CustomerId")]
67 public Customer Customer
69 get { return customer; }
70 set { customer = value; }
73 [Property]
74 public float Total
76 get { return total; }
77 set { total = value; }
80 [Property]
81 public OrderStatus Status
83 get { return status; }
84 set { status = value; }
87 [HasAndBelongsToMany(
88 Table="LineItem",
89 ColumnKey="OrderId", ColumnRef="ProductId", Inverse = true, Lazy = true)]
90 public ISet<Product> Products
92 get { return products; }
93 set { products = value; }