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 TableHierarchySample
17 using System
.Diagnostics
;
18 using Castle
.ActiveRecord
;
19 using Castle
.ActiveRecord
.Framework
.Config
;
23 public static void Main()
25 ActiveRecordStarter
.Initialize(
26 new XmlConfigurationSource("../appconfig.xml"),
27 typeof(Company
), typeof(Client
), typeof(Firm
), typeof(Person
) );
29 // If you want to let AR to create the schema
31 ActiveRecordStarter
.CreateSchema();
39 using(new SessionScope())
41 Company company
= new Company("Stronghold");
44 Firm firm
= new Firm("Johnson & Norman");
47 Client client
= new Client("hammett", firm
);
53 using(new SessionScope())
55 Company
[] companies
= Company
.FindAll();
56 Debug
.Assert(companies
.Length
== 3);
58 Firm
[] firms
= Firm
.FindAll();
59 Debug
.Assert(firms
.Length
== 1);
61 Client
[] clients
= Client
.FindAll();
62 Debug
.Assert(clients
.Length
== 1);
66 // Drop the schema if you want
67 // ActiveRecordStarter.DropSchema();