Fixing an issue with output parameters that are of type IntPtr
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / CompositeModel / Org.cs
blobc6c82b49d877dea23f95fa7288da732a5e6acc9d
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.CompositeModel
17 using System;
18 using System.Collections;
20 [ActiveRecord("Orgs")]
21 public class Org : ActiveRecordBase
23 private string _id;
24 private String _description;
25 private DateTime _created;
26 private IList _agents;
27 private int _version;
29 public Org()
31 _agents = new ArrayList();
32 _created = DateTime.Now;
33 _version = -1;
36 public Org(string id, String description) : this()
38 _id = id;
39 _description = description;
42 [PrimaryKey(PrimaryKeyType.Assigned)]
43 public string Id
45 get { return _id; }
46 set { _id = value; }
49 [Version(UnsavedValue="negative")]
50 public int Version
52 get { return _version; }
53 set { _version = value; }
56 [Property(ColumnType="StringClob")]
57 public String Contents
59 get { return _description; }
60 set { _description = value; }
63 [HasMany(typeof(Agent),
64 Inverse=true,
65 Lazy=true)]
66 public IList Agents
68 get { return _agents; }
69 set { _agents = value; }
72 [Property]
73 public DateTime Created
75 get { return _created; }
76 set { _created = value; }
79 protected override bool BeforeSave(IDictionary state)
81 state["Created"] = DateTime.Now;
82 return true;
85 public static void DeleteAll()
87 DeleteAll(typeof(Org));
90 public static Org[] FindAll()
92 return (Org[]) FindAll(typeof(Org));
95 public static Org Find(string id)
97 return (Org) FindByPrimaryKey(typeof(Org), id);
100 public static int FetchCount()
102 return Count(typeof(Org));
105 public static int FetchCount(string filter, params object[] args)
107 return Count(typeof(Org), filter, args);
110 public void SaveWithException()
112 Save();
114 throw new ApplicationException("Fake Exception");