Refactored the Kernel registration fluent interface to be more readable, better suppo...
[castle.git] / Facilities / ActiveRecordIntegration / Castle.Facilities.ActiveRecordIntegration.Tests / Model / Blog.cs
blob81c518c4ec0da225ecafa703c7a94cc5ea60d114
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.Facilities.ActiveRecordIntegration.Tests
17 using System;
18 using System.Collections;
20 using Castle.ActiveRecord;
23 [ActiveRecord("Blogs")]
24 public class Blog : ActiveRecordBase
26 private int _id;
27 private String _name;
28 private String _author;
29 private IList _posts;
30 private IList _publishedposts;
31 private IList _unpublishedposts;
32 private IList _recentposts;
34 [PrimaryKey(PrimaryKeyType.Native)]
35 public int Id
37 get { return _id; }
38 set { _id = value; }
41 [Property]
42 public String Name
44 get { return _name; }
45 set { _name = value; }
48 [Property]
49 public String Author
51 get { return _author; }
52 set { _author = value; }
55 [HasMany(typeof(Post), Table="Posts", ColumnKey="blogid")]
56 public IList Posts
58 get { return _posts; }
59 set { _posts = value; }
62 [HasMany(typeof(Post), Table="Posts", ColumnKey="blogid", Where="published = 1")]
63 public IList PublishedPosts
65 get { return _publishedposts; }
66 set { _publishedposts = value; }
69 [HasMany(typeof(Post), Table="Posts", ColumnKey="blogid", Where="published = 0")]
70 public IList UnPublishedPosts
72 get { return _unpublishedposts; }
73 set { _unpublishedposts = value; }
76 [HasMany(typeof(Post), 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 ActiveRecordBase.DeleteAll( typeof(Blog) );
88 public static Blog[] FindAll()
90 return (Blog[]) ActiveRecordBase.FindAll( typeof(Blog) );
93 public static Blog Find(int id)
95 return (Blog) ActiveRecordBase.FindByPrimaryKey( typeof(Blog), id );