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

◆ GetParentRow()

static DataRow System.Data.DataRelation.GetParentRow ( DataKey parentKey,
DataKey childKey,
DataRow childRow,
DataRowVersion version )
inlinestaticpackage

Definition at line 403 of file DataRelation.cs.

404 {
405 if (!childRow.HasVersion((version == DataRowVersion.Original) ? DataRowVersion.Original : DataRowVersion.Current) && childRow._tempRecord == -1)
406 {
407 return null;
408 }
409 object[] keyValues = childRow.GetKeyValues(childKey, version);
410 if (IsKeyNull(keyValues))
411 {
412 return null;
413 }
414 Index sortIndex = parentKey.GetSortIndex((version == DataRowVersion.Original) ? DataViewRowState.OriginalRows : DataViewRowState.CurrentRows);
415 Range range = sortIndex.FindRecords(keyValues);
416 if (range.IsNull)
417 {
418 return null;
419 }
420 if (range.Count > 1)
421 {
422 throw ExceptionBuilder.MultipleParents();
423 }
424 return parentKey.Table._recordManager[sortIndex.GetRecord(range.Min)];
425 }
static bool IsKeyNull(object[] values)

References System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Data.DataRelation.IsKeyNull(), and System.Data.ExceptionBuilder.MultipleParents().

Referenced by System.Data.ForeignKeyConstraint.CheckConstraint(), and System.Data.DataRow.GetParentRow().