Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / BlogLazy.cs
bloba7abc84a300438f87784e32ffdddd6db2a3fd496
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
17 using System;
18 using System.Collections;
20 using NHibernate;
22 using Castle.ActiveRecord.Framework;
25 [ActiveRecord("BlogTable")]
26 public class BlogLazy : ActiveRecordBase
28 private int _id;
29 private String _name;
30 private String _author;
31 private IList _posts;
32 private IList _publishedposts;
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(PostLazy), Table="Posts", ColumnKey="blogid", Lazy=true)]
56 public IList Posts
58 get { return _posts; }
59 set { _posts = value; }
62 [HasMany(typeof(PostLazy), Table="Posts", ColumnKey="blogid", Where="published = 1", Lazy=true)]
63 public IList PublishedPosts
65 get { return _publishedposts; }
66 set { _publishedposts = value; }
69 public static void DeleteAll()
71 ActiveRecordBase.DeleteAll( typeof(BlogLazy) );
74 public static BlogLazy[] FindAll()
76 return (BlogLazy[]) ActiveRecordBase.FindAll( typeof(BlogLazy) );
79 public static BlogLazy Find(int id)
81 return (BlogLazy) ActiveRecordBase.FindByPrimaryKey( typeof(BlogLazy), id );
84 /// <summary>
85 /// We make it visible only to for test cases' assertions
86 /// </summary>
87 public static ISessionFactoryHolder Holder
89 get { return ActiveRecordMediator.GetSessionFactoryHolder(); }
92 public void CustomAction()
94 Execute(new NHibernateDelegate(MyCustomMethod));
97 private object MyCustomMethod(ISession session, object blogInstance)
99 session.Delete(blogInstance);
100 session.Flush();
102 return null;