Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / Order.cs
blob040dbe3b3daf7a3a757c6fc9e947f3a0bc0cbaad
1 // Copyright 2004-2008 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 Castle.ActiveRecord.Tests.Model
17 using System;
18 using System.Collections;
20 using Iesi.Collections;
23 [ActiveRecord("`Order`")]
24 public class Order : ActiveRecordBase
26 private int id;
27 private DateTime ordered_date;
28 private Boolean shipped;
29 private ISet _products;
31 [PrimaryKey(PrimaryKeyType.Native, "OrderID")]
32 public int ID
34 get { return this.id; }
35 set { this.id = value; }
38 [Property()]
39 public DateTime OrderedDate
41 get { return this.ordered_date; }
42 set { this.ordered_date = value; }
45 [Property()]
46 public Boolean IsShipped
48 get { return this.shipped; }
49 set { this.shipped = value; }
52 public static Order Find(int id)
54 return ((Order) (ActiveRecordBase.FindByPrimaryKey(typeof (Order), id)));
57 [HasAndBelongsToMany(typeof (Product), RelationType.Set,
58 Table="line_item",
59 ColumnRef="product_id", ColumnKey="order_id")]
60 public ISet Products
62 get { return _products; }
63 set { _products = value; }
66 public static void DeleteAll()
68 ActiveRecordBase.DeleteAll(typeof (Order));
72 [ActiveRecord("`Order`")]
73 public class OrderWithIDBag : ActiveRecordBase
75 private int id;
76 private DateTime ordered_date;
77 private Boolean shipped;
78 private IList _products;
80 [PrimaryKey(PrimaryKeyType.Native, "OrderID")]
81 public int ID
83 get { return this.id; }
84 set { this.id = value; }
87 [Property()]
88 public DateTime OrderedDate
90 get { return this.ordered_date; }
91 set { this.ordered_date = value; }
94 [Property()]
95 public Boolean IsShipped
97 get { return this.shipped; }
98 set { this.shipped = value; }
101 public static OrderWithIDBag Find(int id)
103 return ((OrderWithIDBag) (ActiveRecordBase.FindByPrimaryKey(typeof (OrderWithIDBag), id)));
106 [HasAndBelongsToMany(typeof (ProductWithIDBag), RelationType.IdBag,
107 Table="line_item_non_ident",
108 ColumnRef="product_id", ColumnKey="order_id"),
109 CollectionID(CollectionIDType.HiLo, "line_number", "Int32"),
110 Hilo(Table="testing_hilo", Column="sequence", MaxLo=150)]
111 public IList Products
113 get { return _products; }
114 set { _products = value; }
117 public static void DeleteAll()
119 ActiveRecordBase.DeleteAll(typeof (OrderWithIDBag));