Fixing an issue with output parameters that are of type IntPtr
[castle.git] / Samples / ActiveRecord / TableHierarchySample / App.cs
blob23c496f5f01999d3124b31c15a9b2167644c7945
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 TableHierarchySample
17 using System.Diagnostics;
18 using Castle.ActiveRecord;
19 using Castle.ActiveRecord.Framework.Config;
21 public class App
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();
33 // Common usage
35 Client.DeleteAll();
36 Firm.DeleteAll();
37 Company.DeleteAll();
39 using(new SessionScope())
41 Company company = new Company("Stronghold");
42 company.Create();
44 Firm firm = new Firm("Johnson & Norman");
45 firm.Create();
47 Client client = new Client("hammett", firm);
48 client.Create();
51 // Now let's load
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();