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
.Model
18 using System
.Collections
;
21 [ActiveRecord("Companies", DiscriminatorColumn
="type", DiscriminatorType
="String", DiscriminatorValue
="company")]
22 public class Company
: ActiveRecordBase
26 private IList _people
;
27 private PostalAddress _address
;
33 public Company(string name
)
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" )]
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
;
87 private String _state
;
88 private String _zipcode
;
90 public PostalAddress()
94 public PostalAddress(String address
, String city
,
95 String state
, String zipcode
)
104 public String Address
106 get { return _address; }
107 set { _address = value; }
113 get { return _city; }
114 set { _city = value;}
120 get { return _state; }
121 set { _state = value; }
125 public String ZipCode
127 get { return _zipcode; }
128 set { _zipcode = value; }