Added RedirectUsingNamedRoute
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / Company.cs
blobfeccb6cd713542d730585f2034ad0ea77c0cb603
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.Model
17 using System;
18 using System.Collections;
21 [ActiveRecord("Companies", DiscriminatorColumn="type", DiscriminatorType="String", DiscriminatorValue="company")]
22 public class Company : ActiveRecordBase
24 private int id;
25 private String name;
26 private IList _people;
27 private PostalAddress _address;
29 public Company()
33 public Company(string name)
35 this.name = name;
38 [PrimaryKey]
39 public int Id
41 get { return id; }
42 set { id = value; }
45 [Property]
46 public String Name
48 get { return name; }
49 set { name = value; }
52 [Nested]
53 public PostalAddress Address
55 get { return _address; }
56 set { _address = value; }
59 [HasAndBelongsToMany( typeof(Person), RelationType.Bag,
60 Table="PeopleCompanies", ColumnRef="person_id", ColumnKey="company_id" )]
61 public IList People
63 get { return _people; }
64 set { _people = value; }
67 public static void DeleteAll()
69 ActiveRecordBase.DeleteAll( typeof(Company) );
72 public static Company[] FindAll()
74 return (Company[]) ActiveRecordBase.FindAll( typeof(Company) );
77 public static Company Find(int id)
79 return (Company) ActiveRecordBase.FindByPrimaryKey( typeof(Company), id );
83 public class PostalAddress
85 private String _address;
86 private String _city;
87 private String _state;
88 private String _zipcode;
90 public PostalAddress()
94 public PostalAddress(String address, String city,
95 String state, String zipcode)
97 _address = address;
98 _city = city;
99 _state = state;
100 _zipcode = zipcode;
103 [Property]
104 public String Address
106 get { return _address; }
107 set { _address = value; }
110 [Property]
111 public String City
113 get { return _city; }
114 set { _city = value;}
117 [Property]
118 public String State
120 get { return _state; }
121 set { _state = value; }
124 [Property]
125 public String ZipCode
127 get { return _zipcode; }
128 set { _zipcode = value; }