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("BlogTable")]
24 public class OtherDbBlog
: Test2ARBase
28 private String _author
;
30 private IList _publishedposts
;
31 private IList _unpublishedposts
;
32 private IList _recentposts
;
34 [PrimaryKey(PrimaryKeyType
.Native
)]
45 set { _name = value; }
51 get { return _author; }
52 set { _author = value; }
55 [HasMany(typeof(OtherDbPost
), Table
="Posts", ColumnKey
="blogid")]
58 get { return _posts; }
59 set { _posts = value; }
62 [HasMany(typeof (OtherDbPost
), Table
="Posts", ColumnKey
="blogid", Where
="published = 1")]
63 public IList PublishedPosts
65 get { return _publishedposts; }
66 set { _publishedposts = value; }
69 [HasMany(typeof (OtherDbPost
), Table
="Posts", ColumnKey
="blogid", Where
="published = 0")]
70 public IList UnPublishedPosts
72 get { return _unpublishedposts; }
73 set { _unpublishedposts = value; }
76 [HasMany(typeof (OtherDbPost
), Table
="Posts", ColumnKey
="blogid", OrderBy
="created desc")]
77 public IList RecentPosts
79 get { return _recentposts; }
80 set { _recentposts = value; }
83 public static void DeleteAll()
85 ActiveRecordMediator
.DeleteAll(typeof (OtherDbBlog
));
88 public static OtherDbBlog
[] FindAll()
90 return (OtherDbBlog
[]) ActiveRecordMediator
.FindAll(typeof (OtherDbBlog
));
93 public static OtherDbBlog
Find(int id
)
95 return (OtherDbBlog
) ActiveRecordMediator
.FindByPrimaryKey(typeof (OtherDbBlog
), id
);