Refactored the Kernel registration fluent interface to be more readable, better suppo...
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / Nested / Operation.cs
blob27e2a21acce94fdaf60d63efb1d2fd8dc7abf813
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.Nested
17 using System;
18 using System.Collections;
20 [ActiveRecord]
21 public class Operation : ActiveRecordBase
23 private int id;
24 private PaymentPlan paymentPlan;
26 [PrimaryKey(PrimaryKeyType.Native)]
27 public int Id
29 get { return id; }
30 set { id = value; }
33 [Nested]
34 public PaymentPlan PaymentPlan
36 get { return paymentPlan; }
37 set { paymentPlan = value; }
40 public static void DeleteAll()
42 DeleteAll(typeof(Operation));
45 public static Operation[] FindAll()
47 return (Operation[]) FindAll(typeof(Operation));
50 public static Operation Find(int id)
52 return (Operation) FindByPrimaryKey(typeof(Operation), id);
56 public class PaymentPlan
58 private DateTime expirationDate;
59 private int numberOfPayments;
60 private Convention convention;
61 private IList payments;
63 [Property]
64 public DateTime ExpirationDate
66 get { return expirationDate; }
67 set { expirationDate = value; }
70 [Property]
71 public int NumberOfPayments
73 get { return numberOfPayments; }
74 set { numberOfPayments = value; }
77 [BelongsTo()]
78 public Convention Convention
80 get { return convention; }
81 set { convention = value; }
84 [HasMany(typeof(Payment), "PaymentPlan", "Payment")]
85 public IList Payments
87 get { return payments; }
88 set { payments = value; }
92 [ActiveRecord]
93 public class Convention : ActiveRecordBase
95 private int id;
96 private string description;
98 [PrimaryKey(PrimaryKeyType.Native)]
99 public int Id
101 get { return id; }
102 set { id = value; }
105 [Property]
106 public string Description
108 get { return description; }
109 set { description = value; }
113 [ActiveRecord]
114 public class Payment : ActiveRecordBase
116 private int id;
117 private int amount;
118 private DateTime expiration;
119 // private PaymentPlan paymentPlan;
121 [PrimaryKey(PrimaryKeyType.Native)]
122 public int Id
124 get { return id; }
125 set { id = value; }
128 [Property]
129 public int Amount
131 get { return amount; }
132 set { amount = value; }
135 [Property]
136 public DateTime Expiration
138 get { return expiration; }
139 set { expiration = value; }
142 // NH does not support a many-to-one (BelongsTo in AR) relation
143 // to a composite (nested in AR) class.
144 // [BelongsTo]
145 // public PaymentPlan PaymentPlan
146 // {
147 // get { return paymentPlan; }
148 // set { paymentPlan = value; }
149 // }