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
.Nested
18 using System
.Collections
;
21 public class Operation
: ActiveRecordBase
24 private PaymentPlan paymentPlan
;
26 [PrimaryKey(PrimaryKeyType
.Native
)]
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
;
64 public DateTime ExpirationDate
66 get { return expirationDate; }
67 set { expirationDate = value; }
71 public int NumberOfPayments
73 get { return numberOfPayments; }
74 set { numberOfPayments = value; }
78 public Convention Convention
80 get { return convention; }
81 set { convention = value; }
84 [HasMany(typeof(Payment
), "PaymentPlan", "Payment")]
87 get { return payments; }
88 set { payments = value; }
93 public class Convention
: ActiveRecordBase
96 private string description
;
98 [PrimaryKey(PrimaryKeyType
.Native
)]
106 public string Description
108 get { return description; }
109 set { description = value; }
114 public class Payment
: ActiveRecordBase
118 private DateTime expiration
;
119 // private PaymentPlan paymentPlan;
121 [PrimaryKey(PrimaryKeyType
.Native
)]
131 get { return amount; }
132 set { amount = value; }
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.
145 // public PaymentPlan PaymentPlan
147 // get { return paymentPlan; }
148 // set { paymentPlan = value; }