Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / PostLazy.cs
bloba17a7ecafaa23f68d5e734bc51d60667f6604a57
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 [ActiveRecord("PostTable", Lazy=true)]
21 public class PostLazy : ActiveRecordBase
23 private int _id;
24 private String _title;
25 private String _contents;
26 private String _category;
27 private DateTime _created;
28 private bool _published;
29 private BlogLazy _blog;
31 public PostLazy()
35 public PostLazy(BlogLazy blog, String title, String contents, String category)
37 _blog = blog;
38 _title = title;
39 _contents = contents;
40 _category = category;
43 [PrimaryKey(PrimaryKeyType.Native)]
44 public virtual int Id
46 get { return _id; }
47 set { _id = value; }
50 [Property]
51 public virtual String Title
53 get { return _title; }
54 set { _title = value; }
57 [Property(ColumnType="StringClob")]
58 public virtual String Contents
60 get { return _contents; }
61 set { _contents = value; }
64 [Property]
65 public virtual String Category
67 get { return _category; }
68 set { _category = value; }
71 [BelongsTo("blogid")]
72 public virtual BlogLazy Blog
74 get { return _blog; }
75 set { _blog = value; }
78 [Property("created")]
79 public virtual DateTime Created
81 get { return _created; }
82 set { _created = value; }
85 [Property("published")]
86 public virtual bool Published
88 get { return _published; }
89 set { _published = value; }
92 protected override bool BeforeSave(IDictionary state)
94 state["Created"] = DateTime.Now;
95 return true;
98 public static void DeleteAll()
100 ActiveRecordBase.DeleteAll( typeof(PostLazy) );
103 public static PostLazy[] FindAll()
105 return (PostLazy[]) ActiveRecordBase.FindAll( typeof(PostLazy) );
108 public static PostLazy Find(int id)
110 return (PostLazy) FindByPrimaryKey(typeof (PostLazy), id);
113 public virtual void SaveWithException()
115 Save();
117 throw new ApplicationException("Fake Exception");