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
.Generator
.Components
19 using Castle
.ActiveRecord
.Generator
.Components
.Database
;
21 public enum AssociationEnum
29 public interface IRelationshipBuilder
31 ActiveRecordPropertyRelationDescriptor
Build(RelationshipInfo info
);
34 public class RelationshipInfo
36 private AssociationEnum association
;
37 private TableDefinition associationTable
;
38 private ColumnDefinition parentCol
;
39 private ColumnDefinition childCol
;
40 private ActiveRecordDescriptor descriptor
;
41 private ActiveRecordDescriptor targetDescriptor
;
43 private String orderBy
;
44 private String outerJoin
;
45 private String cascade
;
48 private bool useProxy
;
52 public RelationshipInfo(AssociationEnum association
, ActiveRecordDescriptor descriptor
, ActiveRecordDescriptor targetDescriptor
)
54 if (association
== AssociationEnum
.Undefined
) throw new ArgumentException("association");
55 if (descriptor
== null) throw new ArgumentNullException("descriptor");
56 if (targetDescriptor
== null) throw new ArgumentNullException("targetDescriptor");
58 this.association
= association
;
59 this.descriptor
= descriptor
;
60 this.targetDescriptor
= targetDescriptor
;
63 public AssociationEnum Association
65 get { return association; }
68 public ActiveRecordDescriptor Descriptor
70 get { return descriptor; }
73 public ActiveRecordDescriptor TargetDescriptor
75 get { return targetDescriptor; }
78 public TableDefinition AssociationTable
80 get { return associationTable; }
81 set { associationTable = value; }
84 public ColumnDefinition ParentCol
86 get { return parentCol; }
87 set { parentCol = value; }
90 public ColumnDefinition ChildCol
92 get { return childCol; }
93 set { childCol = value; }
99 set { where = value; }
102 public string OrderBy
104 get { return orderBy; }
105 set { orderBy = value; }
108 public string OuterJoin
110 get { return outerJoin; }
111 set { outerJoin = value; }
116 get { return useProxy; }
117 set { useProxy = value; }
122 get { return invert; }
123 set { invert = value; }
126 public String Cascade
128 get { return cascade; }
129 set { cascade = value; }
134 get { return insert; }
135 set { insert = value; }
140 get { return update; }
141 set { update = value; }
147 set { lazy = value; }