Applied patch from Jan Limpens 'ReflectionBasedDictionaryAdapter needs to check if...
[castle.git] / ActiveRecord / Castle.ActiveRecord.Tests / Model / GenericModel / Company.cs
blob1a69f63a329e2f7d8e64310fdbe28b6aceb8b80e
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.GenericModel
17 using System;
18 using System.Collections;
19 using Iesi.Collections.Generic;
21 [ActiveRecord( "Companies", DiscriminatorColumn = "type", DiscriminatorType = "String", DiscriminatorValue = "company" )]
22 public class Company : ActiveRecordBase<Company>
24 private int id;
25 private String name;
26 private ISet<Person> _people = new HashedSet<Person>();
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(Table = "PeopleCompanies",
60 ColumnRef = "person_id", ColumnKey = "company_id" )]
61 public ISet<Person> People
63 get { return _people; }
64 set { _people = value; }
69 public class PostalAddress
71 private String _address;
72 private String _city;
73 private String _state;
74 private String _zipcode;
76 public PostalAddress()
80 public PostalAddress( String address, String city,
81 String state, String zipcode )
83 _address = address;
84 _city = city;
85 _state = state;
86 _zipcode = zipcode;
89 [Property]
90 public String Address
92 get { return _address; }
93 set { _address = value; }
96 [Property]
97 public String City
99 get { return _city; }
100 set { _city = value; }
103 [Property]
104 public String State
106 get { return _state; }
107 set { _state = value; }
110 [Property]
111 public String ZipCode
113 get { return _zipcode; }
114 set { _zipcode = value; }