Fixing an issue with output parameters that are of type IntPtr
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / Post.cs
blob42ee7b4af26454113b847f4d3b85c0b9f3452b37
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;
18 using System.Collections;
20 [ActiveRecord("PostTable")]
21 public class Post : ActiveRecordBase
23 private int _id;
24 private String _title;
25 private String _contents;
26 private String _category;
27 private DateTime _created;
28 private bool _published;
29 private Blog _blog;
31 public Post()
35 public Post(Blog blog, String title, String contents, String category)
37 _blog = blog;
38 _title = title;
39 _contents = contents;
40 _category = category;
43 [PrimaryKey(PrimaryKeyType.Native)]
44 public int Id
46 get { return _id; }
47 set { _id = value; }
50 [Property]
51 public String Title
53 get { return _title; }
54 set { _title = value; }
57 [Property(ColumnType="StringClob")]
58 public String Contents
60 get { return _contents; }
61 set { _contents = value; }
64 [Property]
65 public String Category
67 get { return _category; }
68 set { _category = value; }
71 [BelongsTo("blogid")]
72 public Blog Blog
74 get { return _blog; }
75 set { _blog = value; }
78 [Property("created")]
79 public DateTime Created
81 get { return _created; }
82 set { _created = value; }
85 [Property("published")]
86 public bool Published
88 get { return _published; }
89 set { _published = value; }
92 protected override bool BeforeSave(IDictionary state)
94 state["Created"] = DateTime.Now;
95 return true;
98 public static void DeleteAll()
100 DeleteAll(typeof(Post));
103 public static Post[] FindAll()
105 return (Post[]) FindAll(typeof(Post));
108 public static Post Find(int id)
110 return (Post) FindByPrimaryKey(typeof(Post), id);
113 public static int FetchCount()
115 return Count(typeof(Post));
118 public static int FetchCount(string filter, params object[] args)
120 return Count(typeof(Post), filter, args);
123 public void SaveWithException()
125 Save();
127 throw new ApplicationException("Fake Exception");