comparison Source/Mapping/Fluent/MapFieldMap.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Collections.Generic;
3 using System.Data;
4 using System.Linq.Expressions;
5
6 using BLToolkit.Reflection.Extension;
7
8 namespace BLToolkit.Mapping.Fluent
9 {
10 /// <summary>
11 /// Fluent settings for field
12 /// </summary>
13 /// <typeparam name="T"></typeparam>
14 /// <typeparam name="TR"></typeparam>
15 public partial class MapFieldMap<T, TR> : FluentMap<T>
16 {
17 private readonly Expression<Func<T, TR>> _prop;
18
19 public MapFieldMap(TypeExtension owner, List<IFluentMap> childs, Expression<Func<T, TR>> prop)
20 : base(owner, childs)
21 {
22 this._prop = prop;
23 }
24
25 /// <summary>
26 /// PrimaryKeyAttribute
27 /// </summary>
28 /// <typeparam name="TR"></typeparam>
29 /// <param name="order"></param>
30 /// <returns></returns>
31 public MapFieldMap<T, TR> PrimaryKey(int order = -1)
32 {
33 return this.PrimaryKey(this._prop, order);
34 }
35
36 public MapFieldMap<T, TR> LazyInstance(bool isLazy = true)
37 {
38 return this.LazyInstance(this._prop, isLazy);
39 }
40
41
42 /// <summary>
43 /// NonUpdatableAttribute
44 /// </summary>
45 /// <returns></returns>
46 public MapFieldMap<T, TR> NonUpdatable()
47 {
48 return this.NonUpdatable(this._prop);
49 }
50
51 /// <summary>
52 /// IdentityAttribute
53 /// </summary>
54 /// <typeparam name="TR"></typeparam>
55 /// <returns></returns>
56 public MapFieldMap<T, TR> Identity()
57 {
58 return this.Identity(this._prop);
59 }
60
61 /// <summary>
62 /// SqlIgnoreAttribute
63 /// </summary>
64 /// <param name="ignore"></param>
65 /// <returns></returns>
66 public MapFieldMap<T, TR> SqlIgnore(bool ignore = true)
67 {
68 return this.SqlIgnore(this._prop, ignore);
69 }
70
71 /// <summary>
72 /// MapIgnoreAttribute
73 /// </summary>
74 /// <param name="ignore"></param>
75 /// <returns></returns>
76 public MapFieldMap<T, TR> MapIgnore(bool ignore = true)
77 {
78 return this.MapIgnore(this._prop, ignore);
79 }
80
81 /// <summary>
82 /// TrimmableAttribute
83 /// </summary>
84 /// <returns></returns>
85 public MapFieldMap<T, TR> Trimmable()
86 {
87 return this.Trimmable(this._prop);
88 }
89
90 /// <summary>
91 /// MapValueAttribute
92 /// </summary>
93 /// <typeparam name="TV"> </typeparam>
94 /// <param name="origValue"></param>
95 /// <param name="value"></param>
96 /// <param name="values"></param>
97 /// <returns></returns>
98 public MapFieldMap<T, TR> MapValue<TV>(TR origValue, TV value, params TV[] values)
99 {
100 return this.MapValue(this._prop, origValue, value, values);
101 }
102
103 /// <summary>
104 /// DefaultValueAttribute
105 /// </summary>
106 /// <param name="value"></param>
107 /// <returns></returns>
108 public MapFieldMap<T, TR> DefaultValue(TR value)
109 {
110 return this.DefaultValue(this._prop, value);
111 }
112
113 /// <summary>
114 /// DbTypeAttribute
115 /// </summary>
116 /// <param name="dbType"></param>
117 /// <returns></returns>
118 public MapFieldMap<T, TR> DbType(DbType dbType)
119 {
120 return this.DbType(this._prop, dbType);
121 }
122
123 /// <summary>
124 /// MemberMapperAttribute
125 /// at the Moment you also have to specify MapIgnore(false) when using Complex types with Member Mapper.
126 /// </summary>
127 /// <param name="value"></param>
128 /// <returns></returns>
129 public MapFieldMap<T, TR> MemberMapper(Type memberMapperType)
130 {
131 return this.MemberMapper(this._prop, memberMapperType);
132 }
133
134 /// <summary>
135 /// MemberMapperAttribute
136 /// at the Moment you also have to specify MapIgnore(false) when using Complex types with Member Mapper.
137 /// </summary>
138 /// <param name="value"></param>
139 /// <returns></returns>
140 public MapFieldMap<T, TR> MemberMapper(Type memberType, Type memberMapperType)
141 {
142 return this.MemberMapper(this._prop, memberType, memberMapperType);
143 }
144
145 /// <summary>
146 /// NullableAttribute
147 /// </summary>
148 /// <param name="isNullable"></param>
149 /// <returns></returns>
150 public MapFieldMap<T, TR> Nullable(bool isNullable = true)
151 {
152 return this.Nullable(this._prop, isNullable);
153 }
154
155 /// <summary>
156 /// NullValueAttribute
157 /// </summary>
158 /// <param name="value"></param>
159 /// <returns></returns>
160 public MapFieldMap<T, TR> NullValue(TR value)
161 {
162 return this.NullValue(this._prop, value);
163 }
164
165 /// <summary>
166 /// AssociationAttribute
167 /// </summary>
168 /// <typeparam name="TRt"></typeparam>
169 /// <param name="canBeNull"></param>
170 /// <param name="thisKey"></param>
171 /// <param name="thisKeys"></param>
172 /// <returns></returns>
173 public AssociationMap<TRt> Association<TRt>(bool canBeNull, Expression<Func<T, TRt>> thisKey, params Expression<Func<T, TRt>>[] thisKeys)
174 {
175 return this.Association(this._prop, canBeNull, thisKey, thisKeys);
176 }
177
178 /// <summary>
179 /// AssociationAttribute
180 /// </summary>
181 /// <typeparam name="TRt"></typeparam>
182 /// <param name="thisKey"></param>
183 /// <param name="thisKeys"></param>
184 /// <returns></returns>
185 public AssociationMap<TRt> Association<TRt>(Expression<Func<T, TRt>> thisKey, params Expression<Func<T, TRt>>[] thisKeys)
186 {
187 return this.Association(this._prop, thisKey, thisKeys);
188 }
189
190 private MapFieldMap<T, TR> Association<TRt, TRf, TRo>(bool canBeNull
191 , IEnumerable<Expression<Func<T, TRt>>> thisKeys, IEnumerable<Expression<Func<TRf, TRo>>> otherKeys)
192 {
193 return this.Association(this._prop, canBeNull, thisKeys, otherKeys);
194 }
195
196 /// <summary>
197 /// RelationAttribute
198 /// </summary>
199 /// <param name="slaveIndex"></param>
200 /// <param name="masterIndex"></param>
201 /// <returns></returns>
202 public MapFieldMap<T, TR> Relation(string slaveIndex = null, string masterIndex = null)
203 {
204 return this.Relation(this._prop, slaveIndex, masterIndex);
205 }
206
207 /// <summary>
208 /// RelationAttribute
209 /// </summary>
210 /// <param name="slaveIndex"></param>
211 /// <param name="masterIndex"></param>
212 /// <returns></returns>
213 public MapFieldMap<T, TR> Relation(string[] slaveIndex, string[] masterIndex)
214 {
215 return this.Relation(this._prop, slaveIndex, masterIndex);
216 }
217 }
218 }