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
20 /// Maps properties of a child object to columns of the table
21 /// of a parent class.
24 /// The following code illustrates the use of a
25 /// nested <c>PostalAddress</c> class
27 /// [ActiveRecord("Companies")]
28 /// public class Company : ActiveRecordBase
31 /// private PostalAddress _address;
37 /// public Company(string name)
45 /// get { return id; }
46 /// set { id = value; }
50 /// public PostalAddress Address
52 /// get { return _address; }
53 /// set { _address = value; }
57 /// public class PostalAddress
59 /// private String _address;
60 /// private String _city;
61 /// private String _state;
62 /// private String _zipcode;
65 /// public String Address
67 /// get { return _address; }
68 /// set { _address = value; }
72 /// public String City
74 /// get { return _city; }
75 /// set { _city = value;}
79 /// public String State
81 /// get { return _state; }
82 /// set { _state = value; }
86 /// public String ZipCode
88 /// get { return _zipcode; }
89 /// set { _zipcode = value; }
94 [AttributeUsage(AttributeTargets
.Property
, AllowMultiple
=false), Serializable
]
95 public class NestedAttribute
: WithAccessAttribute
97 private bool update
= true;
98 private bool insert
= true;
100 private String columnPrefix
;
103 /// Informs ActiveRecord that the marked property contains nested elements, contained
104 /// in a separate, reusable class.
106 public NestedAttribute() {}
109 /// Informs ActiveRecord that the marked property contains nested elements, contained
110 /// in a separate, reusable class.
112 /// <param name="columnPrefix">A prefix to insert before each column in the nested component</param>
113 public NestedAttribute(String columnPrefix
)
115 this.columnPrefix
= columnPrefix
;
119 /// Allows one to reference a different type
120 /// than the property type
124 get { return mapType; }
125 set { mapType = value; }
129 /// Set to <c>false</c> to ignore this nested component when updating entities of this ActiveRecord class.
133 get { return update; }
134 set { update = value; }
138 /// Set to <c>false</c> to ignore this nested component when inserting entities of this ActiveRecord class.
142 get { return insert; }
143 set { insert = value; }
147 /// A prefix to insert before each column in the nested component.
149 public String ColumnPrefix
151 get { return this.columnPrefix; }
152 set { this.columnPrefix = value; }