Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / Entity.cs
blob67cd4b28dd19a0dededd63b33f0d4c931c808f9a
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;
19 [ActiveRecord("entity"), JoinedBase]
20 public class Entity : ActiveRecordBase
22 private int id;
23 private string name;
24 private string type;
26 public Entity()
30 [PrimaryKey]
31 public int Id
33 get { return id; }
34 set { id = value; }
37 [Property]
38 public string Name
40 get { return name; }
41 set { name = value; }
44 [Property]
45 public string Type
47 get { return type; }
48 set { type = value; }
51 public static void DeleteAll()
53 ActiveRecordBase.DeleteAll( typeof(Entity) );
56 public static Entity[] FindAll()
58 return (Entity[]) ActiveRecordBase.FindAll( typeof(Entity) );
61 public static Entity Find(int id)
63 return (Entity) ActiveRecordBase.FindByPrimaryKey( typeof(Entity), id );
67 [ActiveRecord("entitycompany")]
68 public class CompanyEntity : Entity
70 private byte company_type;
71 private int comp_id;
73 [JoinedKey("comp_id")]
74 public int CompId
76 get { return comp_id; }
77 set { comp_id = value; }
80 [Property("company_type")]
81 public byte CompanyType
83 get { return company_type; }
84 set { company_type = value; }
87 public new static void DeleteAll()
89 ActiveRecordBase.DeleteAll( typeof(CompanyEntity) );
92 public new static CompanyEntity[] FindAll()
94 return (CompanyEntity[]) ActiveRecordBase.FindAll( typeof(CompanyEntity) );
97 public new static CompanyEntity Find(int id)
99 return (CompanyEntity) ActiveRecordBase.FindByPrimaryKey( typeof(CompanyEntity), id );
103 [ActiveRecord("entityperson")]
104 public class PersonEntity : Entity
106 private int person_id;
108 [JoinedKey]
109 public int Person_Id
111 get { return person_id; }
112 set { person_id = value; }
115 private IManager manager;
117 [Any(IdType = typeof(int), MetaType = typeof(string), IdColumn = "ManagerId", TypeColumn = "ManagerType")]
118 [Any.MetaValueAttribute("Manager", typeof(ManagerEntity))]
119 public virtual IManager Manager
121 get { return manager; }
122 set { manager = value; }
125 public new static void DeleteAll()
127 ActiveRecordBase.DeleteAll( typeof(PersonEntity) );
130 public new static PersonEntity[] FindAll()
132 return (PersonEntity[]) ActiveRecordBase.FindAll( typeof(PersonEntity) );
135 public new static PersonEntity Find(int id)
137 return (PersonEntity) ActiveRecordBase.FindByPrimaryKey( typeof(PersonEntity), id );
141 [ActiveRecord("entitymanager")]
142 public class ManagerEntity : ActiveRecordBase, IManager
144 private int id;
146 [PrimaryKey]
147 public int Id
149 get { return id; }
150 set { id = value; }
153 private string name;
155 [Property]
156 public virtual string Name
158 get { return name; }
159 set { name = value; }
162 public static void DeleteAll()
164 DeleteAll(typeof(ManagerEntity));
167 public static ManagerEntity[] FindAll()
169 return (ManagerEntity[])FindAll(typeof(ManagerEntity));
172 public static ManagerEntity Find(int id)
174 return (ManagerEntity)FindByPrimaryKey(typeof(ManagerEntity), id);
178 public interface IManager
180 int Id { get; set; }
181 string Name { get; set; }