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
19 [ActiveRecord("entity"), JoinedBase
]
20 public class Entity
: ActiveRecordBase
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
;
73 [JoinedKey("comp_id")]
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
;
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
156 public virtual string 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
181 string Name { get; set; }