Applied patch from Jan Limpens 'ReflectionBasedDictionaryAdapter needs to check if...
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / AnyModel / Models.cs
blob60dfd444865e3ae151d1940b335149558f4c851c
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.AnyModel
17 using System;
18 using System.Collections;
20 [ActiveRecord("Orders")]
21 public class Order : ActiveRecordBase
23 private int id;
24 private IList _payments;
26 public Order()
30 [PrimaryKey]
31 public int Id
33 get { return id; }
34 set { id = value; }
37 [HasManyToAny(typeof(IPayment), "pay_id", "payments_table", typeof(int),
38 "Billing_Details_Type", "Billing_Details_Id", MetaType = typeof(string))]
39 [Any.MetaValue("CREDIT_CARD", typeof(CreditCards))]
40 [Any.MetaValue("BANK_ACCOUNT", typeof(BankAccounts))]
41 public IList Payments
43 get { return _payments; }
44 set { _payments = value; }
48 [ActiveRecord]
49 public class CreditCards : ActiveRecordBase, IPayment
51 private int id;
52 private String name;
53 private Order _order;
55 public CreditCards()
59 [PrimaryKey]
60 public int Id
62 get { return id; }
63 set { id = value; }
66 [BelongsTo("ref_order")]
67 public Order Order
69 get { return _order; }
70 set { _order = value; }
73 [Property]
74 public string Name
76 get { return name; }
77 set { name = value; }
81 [ActiveRecord]
82 public class BankAccounts : ActiveRecordBase, IPayment
84 private int id;
85 private String name;
86 private bool credit;
87 private Order _order;
89 public BankAccounts()
93 [PrimaryKey]
94 public int Id
96 get { return id; }
97 set { id = value; }
100 [BelongsTo("ref_order")]
101 public Order Order
103 get { return _order; }
104 set { _order = value; }
107 [Property]
108 public string Name
110 get { return name; }
111 set { name = value; }
114 [Property]
115 public bool Credit
117 get { return credit; }
118 set { credit = value; }
122 public interface IPayment
124 int Id { get; set; }
125 Order Order { get; set; }
128 [ActiveRecord]
129 public class ModelWithInCorrectMapping : ActiveRecordBase
131 private string payment;
133 [Any.MetaValue("CREDIT_CARD", typeof(CreditCards))]
134 [Any.MetaValue("BANK_ACCOUNT", typeof(BankAccounts))]
135 public string Payment
137 get { return payment; }
138 set { payment = value; }