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
.GenericModel
18 using System
.Collections
;
20 using NHibernate
.Expressions
;
22 [ActiveRecord("PostTable")]
23 public class Post
: ActiveRecordBase
<Post
>
26 private String _title
;
27 private String _contents
;
28 private String _category
;
29 private DateTime _created
;
30 private bool _published
;
37 public Post(Blog blog
, String title
, String contents
, String category
)
55 get { return _title; }
56 set { _title = value; }
59 [Property(ColumnType
="StringClob")]
60 public String Contents
62 get { return _contents; }
63 set { _contents = value; }
67 public String Category
69 get { return _category; }
70 set { _category = value; }
77 set { _blog = value; }
81 public DateTime Created
83 get { return _created; }
84 set { _created = value; }
87 [Property("published")]
90 get { return _published; }
91 set { _published = value; }
94 public void SaveWithException()
98 throw new ApplicationException("Fake Exception");
101 protected override bool BeforeSave(IDictionary state
) {
102 state
["Created"] = DateTime
.Now
;
106 public static Post
[] CustomSlicedFind(ICriterion criteria
, int firstResult
, int maxResults
)
108 return SlicedFindAll(firstResult
, maxResults
, criteria
);