Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Nested

virtual bool System.Data.DataRelation.Nested
getset

Definition at line 183 of file DataRelation.cs.

184 {
185 get
186 {
188 return _nested;
189 }
190 set
191 {
192 long scopeId = DataCommonEventSource.Log.EnterScope("<ds.DataRelation.set_Nested|API> {0}, {1}", ObjectID, value);
193 try
194 {
195 if (_nested == value)
196 {
197 return;
198 }
199 if (_dataSet != null && value)
200 {
201 if (ChildTable.IsNamespaceInherited())
202 {
204 }
205 ChildTable.Constraints.FindForeignKeyConstraint(ChildKey.ColumnsReference, ParentKey.ColumnsReference)?.CheckConstraint();
207 }
208 if (!value && _parentKey.ColumnsReference[0].ColumnMapping == MappingType.Hidden)
209 {
210 throw ExceptionBuilder.RelationNestedReadOnly();
211 }
212 if (value)
213 {
214 ParentTable.Columns.RegisterColumnName(ChildTable.TableName, null);
215 }
216 else
217 {
218 ParentTable.Columns.UnregisterName(ChildTable.TableName);
219 }
220 RaisePropertyChanging("Nested");
221 if (value)
222 {
224 if (DataSet != null)
225 {
226 if (ParentTable == ChildTable)
227 {
228 foreach (DataRow row in ChildTable.Rows)
229 {
230 row.CheckForLoops(this);
231 }
232 if (ChildTable.DataSet != null && string.Compare(ChildTable.TableName, ChildTable.DataSet.DataSetName, ignoreCase: true, ChildTable.DataSet.Locale) == 0)
233 {
234 throw ExceptionBuilder.DatasetConflictingName(DataSet.DataSetName);
235 }
236 ChildTable._fNestedInDataset = false;
237 }
238 else
239 {
240 foreach (DataRow row2 in ChildTable.Rows)
241 {
242 row2.GetParentRow(this);
243 }
244 }
245 }
246 ParentTable.ElementColumnCount++;
247 }
248 else
249 {
250 ParentTable.ElementColumnCount--;
251 }
252 _nested = value;
253 ChildTable.CacheNestedParent();
254 if (!value || !string.IsNullOrEmpty(ChildTable.Namespace) || (ChildTable.NestedParentsCount <= 1 && (ChildTable.NestedParentsCount <= 0 || ChildTable.DataSet.Relations.Contains(RelationName))))
255 {
256 return;
257 }
258 string text = null;
259 foreach (DataRelation parentRelation in ChildTable.ParentRelations)
260 {
261 if (parentRelation.Nested)
262 {
263 if (text == null)
264 {
265 text = parentRelation.ParentTable.Namespace;
266 }
267 else if (!string.Equals(text, parentRelation.ParentTable.Namespace, StringComparison.Ordinal))
268 {
269 _nested = false;
270 throw ExceptionBuilder.InvalidParentNamespaceinNestedRelation(ChildTable.TableName);
271 }
272 }
273 }
274 if (CheckMultipleNested && ChildTable._tableNamespace != null && ChildTable._tableNamespace.Length == 0)
275 {
276 throw ExceptionBuilder.TableCantBeNestedInTwoTables(ChildTable.TableName);
277 }
278 ChildTable._tableNamespace = null;
279 }
280 finally
281 {
282 DataCommonEventSource.Log.ExitScope(scopeId);
283 }
284 }
285 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)
virtual MappingType ColumnMapping
DataRelation(string? relationName, DataColumn parentColumn, DataColumn childColumn)
void RaisePropertyChanging(string name)
virtual DataTable ParentTable
virtual ? DataSet DataSet
virtual DataTable ChildTable
virtual string RelationName
void CheckNamespaceValidityForNestedRelations(string ns)
DataColumn[] ColumnsReference
Definition DataKey.cs:7

Referenced by System.Data.DataRelationCollection.DataSetRelationCollection.AddCore(), System.Data.DataRelationCollection.AddCore(), System.Data.DataRelation.Clone(), System.Data.DataRelationCollection.DataSetRelationCollection.RemoveCore(), System.Data.DataRelationCollection.RemoveCore(), and System.Data.DataRelation.ValidateMultipleNestedRelations().