1 // Copyright 2004-2008 Castle Project - http://www.castleproject.org/
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
7 // http://www.apache.org/licenses/LICENSE-2.0
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
18 using System
.Collections
;
20 using Iesi
.Collections
;
23 [ActiveRecord("`Order`")]
24 public class Order
: ActiveRecordBase
27 private DateTime ordered_date
;
28 private Boolean shipped
;
29 private ISet _products
;
31 [PrimaryKey(PrimaryKeyType
.Native
, "OrderID")]
34 get { return this.id; }
35 set { this.id = value; }
39 public DateTime OrderedDate
41 get { return this.ordered_date; }
42 set { this.ordered_date = value; }
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
,
59 ColumnRef
="product_id", ColumnKey
="order_id")]
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
76 private DateTime ordered_date
;
77 private Boolean shipped
;
78 private IList _products
;
80 [PrimaryKey(PrimaryKeyType
.Native
, "OrderID")]
83 get { return this.id; }
84 set { this.id = value; }
88 public DateTime OrderedDate
90 get { return this.ordered_date; }
91 set { this.ordered_date = value; }
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
));