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
18 using System
.Collections
;
20 using Castle
.ActiveRecord
.Tests
.Model
;
23 [ActiveRecord("PostTable")]
24 public class OtherDbPost
: Test2ARBase
27 private String _title
;
28 private String _contents
;
29 private String _category
;
30 private DateTime _created
;
31 private bool _published
;
32 private OtherDbBlog _blog
;
38 public OtherDbPost(OtherDbBlog blog
, String title
, String contents
, String category
)
46 [PrimaryKey(PrimaryKeyType
.Native
)]
56 get { return _title; }
57 set { _title = value; }
60 [Property(ColumnType
="StringClob")]
61 public String Contents
63 get { return _contents; }
64 set { _contents = value; }
68 public String Category
70 get { return _category; }
71 set { _category = value; }
75 public OtherDbBlog Blog
78 set { _blog = value; }
82 public DateTime Created
84 get { return _created; }
85 set { _created = value; }
88 [Property("published")]
91 get { return _published; }
92 set { _published = value; }
95 protected override bool BeforeSave(IDictionary state
)
97 state
["Created"] = DateTime
.Now
;
101 public static void DeleteAll()
103 ActiveRecordBase
.DeleteAll( typeof(OtherDbPost
) );
106 public static OtherDbPost
[] FindAll()
108 return (OtherDbPost
[]) ActiveRecordBase
.FindAll( typeof(OtherDbPost
) );
111 public static OtherDbPost
Find(int id
)
113 return (OtherDbPost
) ActiveRecordBase
.FindByPrimaryKey( typeof(OtherDbPost
), id
);
116 public void SaveWithException()
120 throw new ApplicationException("Fake Exception");