Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / Product.cs
blobf64cdd92184e3710c810e17eb284b827048a20c6
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.Collections;
18 using Iesi.Collections;
20 [ActiveRecord("Product")]
21 public class Product : ActiveRecordBase
23 private int id;
24 private string product_name;
25 private float price;
26 private string serial_number;
27 private ISet _orders;
29 [PrimaryKey(PrimaryKeyType.Native, "ProductID")]
30 public int ID
32 get { return this.id; }
33 set { this.id = value; }
36 [Property()]
37 public string Name
39 get { return this.product_name; }
40 set { this.product_name = value; }
43 [Property()]
44 public string SerialNumber
46 get { return this.serial_number; }
47 set { this.serial_number = value; }
50 [Property()]
51 public float Price
53 get { return this.price; }
54 set { this.price = value; }
57 [HasAndBelongsToMany(typeof (Order), RelationType.Set,
58 Table="line_item",
59 ColumnRef="order_id", ColumnKey="product_id", Inverse=true)]
60 public ISet Orders
62 get { return _orders; }
63 set { _orders = value; }
66 public static Product Find(int id)
68 return ((Product) (ActiveRecordBase.FindByPrimaryKey(typeof (Product), id)));
71 public static void DeleteAll()
73 ActiveRecordBase.DeleteAll(typeof (Product));
77 [ActiveRecord("Product")]
78 public class ProductWithIDBag : ActiveRecordBase
80 private int id;
81 private string product_name;
82 private float price;
83 private string serial_number;
84 private IList _orders;
86 [PrimaryKey(PrimaryKeyType.Native, "ProductID")]
87 public int ID
89 get { return this.id; }
90 set { this.id = value; }
93 [Property()]
94 public string Name
96 get { return this.product_name; }
97 set { this.product_name = value; }
100 [Property()]
101 public string SerialNumber
103 get { return this.serial_number; }
104 set { this.serial_number = value; }
107 [Property()]
108 public float Price
110 get { return this.price; }
111 set { this.price = value; }
114 [HasAndBelongsToMany(typeof (OrderWithIDBag), RelationType.IdBag,
115 Table="line_item_non_ident",
116 ColumnRef="order_id", ColumnKey="product_id"),
117 CollectionID(CollectionIDType.HiLo, "line_number", "Int32"),
118 Hilo(Table="testing_hilo", Column="sequence", MaxLo=150)]
119 public IList Orders
121 get { return _orders; }
122 set { _orders = value; }
125 public static ProductWithIDBag Find(int id)
127 return ((ProductWithIDBag) (ActiveRecordBase.FindByPrimaryKey(typeof (ProductWithIDBag), id)));
130 public static void DeleteAll()
132 ActiveRecordBase.DeleteAll(typeof (ProductWithIDBag));