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

◆ SetupSchemaWithKeyInfo()

object[] System.Data.ProviderBase.SchemaMapping.SetupSchemaWithKeyInfo ( MissingMappingAction mappingAction,
MissingSchemaAction schemaAction,
bool gettingData,
DataColumn parentChapterColumn,
object chapterValue )
inlineprivate

Definition at line 648 of file SchemaMapping.cs.

649 {
651 if (sortedSchemaRows.Length == 0)
652 {
653 _dataTable = null;
654 return null;
655 }
656 bool flag = (_dataTable.PrimaryKey.Length == 0 && ((LoadOption)4 <= _loadOption || _dataTable.Rows.Count == 0)) || _dataTable.Columns.Count == 0;
657 DataColumn[] array = null;
658 int num = 0;
659 bool flag2 = true;
660 string text = null;
661 string text2 = null;
662 bool flag3 = false;
663 bool flag4 = false;
664 int[] array2 = null;
665 bool[] array3 = null;
666 int num2 = 0;
667 object[] result = null;
668 List<object> items = null;
669 DataColumnCollection columns = _dataTable.Columns;
670 try
671 {
672 for (int i = 0; i < sortedSchemaRows.Length; i++)
673 {
675 int unsortedIndex = dbSchemaRow.UnsortedIndex;
676 bool flag5 = false;
677 Type type = dbSchemaRow.DataType;
678 if (null == type)
679 {
681 }
682 if (null == type)
683 {
685 }
686 if (typeof(IDataReader).IsAssignableFrom(type))
687 {
688 if (array3 == null)
689 {
690 array3 = new bool[sortedSchemaRows.Length];
691 }
692 flag5 = (array3[unsortedIndex] = true);
693 type = typeof(int);
694 }
695 else if (typeof(SqlXml).IsAssignableFrom(type))
696 {
697 if (_xmlMap == null)
698 {
699 _xmlMap = new int[sortedSchemaRows.Length];
700 }
701 _xmlMap[i] = 1;
702 }
703 else if (typeof(XmlReader).IsAssignableFrom(type))
704 {
705 type = typeof(string);
706 if (_xmlMap == null)
707 {
708 _xmlMap = new int[sortedSchemaRows.Length];
709 }
710 _xmlMap[i] = 2;
711 }
712 DataColumn dataColumn = null;
713 if (!dbSchemaRow.IsHidden)
714 {
716 }
717 string baseTableName = dbSchemaRow.BaseTableName;
718 if (dataColumn == null)
719 {
720 if (array2 == null)
721 {
723 }
724 array2[unsortedIndex] = -1;
725 if (dbSchemaRow.IsKey && (flag3 || dbSchemaRow.BaseTableName == text))
726 {
727 flag = false;
728 array = null;
729 }
730 continue;
731 }
732 if (_xmlMap != null && _xmlMap[i] != 0)
733 {
734 if (typeof(SqlXml) == dataColumn.DataType)
735 {
736 _xmlMap[i] = 1;
737 }
738 else if (typeof(XmlDocument) == dataColumn.DataType)
739 {
740 _xmlMap[i] = 2;
741 }
742 else
743 {
744 _xmlMap[i] = 0;
745 int num3 = 0;
746 for (int j = 0; j < _xmlMap.Length; j++)
747 {
748 num3 += _xmlMap[j];
749 }
750 if (num3 == 0)
751 {
752 _xmlMap = null;
753 }
754 }
755 }
756 if (dbSchemaRow.IsKey && baseTableName != text)
757 {
758 if (text == null)
759 {
761 }
762 else
763 {
764 flag3 = true;
765 }
766 }
767 if (flag5)
768 {
769 if (dataColumn.Table == null)
770 {
773 dataColumn.ReadOnly = true;
774 }
775 else if (!dataColumn.AutoIncrement)
776 {
778 }
779 }
780 else
781 {
782 if (!flag4 && baseTableName != text2 && !string.IsNullOrEmpty(baseTableName))
783 {
784 if (text2 == null)
785 {
787 }
788 else
789 {
790 flag4 = true;
791 }
792 }
793 if ((LoadOption)4 <= _loadOption)
794 {
795 if (dbSchemaRow.IsAutoIncrement && DataColumn.IsAutoIncrementType(type))
796 {
798 if (!dbSchemaRow.AllowDBNull)
799 {
801 }
802 }
803 if (type == typeof(string))
804 {
805 dataColumn.MaxLength = ((dbSchemaRow.Size > 0) ? dbSchemaRow.Size : (-1));
806 }
808 {
809 dataColumn.ReadOnly = true;
810 }
811 if (!dbSchemaRow.AllowDBNull && (!dbSchemaRow.IsReadOnly || dbSchemaRow.IsKey))
812 {
814 }
815 if (dbSchemaRow.IsUnique && !dbSchemaRow.IsKey && !type.IsArray)
816 {
817 dataColumn.Unique = true;
818 if (!dbSchemaRow.AllowDBNull)
819 {
821 }
822 }
823 }
824 else if (dataColumn.Table == null)
825 {
826 dataColumn.AutoIncrement = dbSchemaRow.IsAutoIncrement;
830 if (type == typeof(string) || type == typeof(SqlString))
831 {
833 }
834 }
835 }
836 if (dataColumn.Table == null)
837 {
838 if ((LoadOption)4 > _loadOption)
839 {
841 }
844 }
845 if (flag && dbSchemaRow.IsKey)
846 {
847 if (array == null)
848 {
849 array = new DataColumn[sortedSchemaRows.Length];
850 }
851 array[num++] = dataColumn;
852 if (flag2 && dataColumn.AllowDBNull)
853 {
854 flag2 = false;
855 }
856 }
857 if (array2 != null)
858 {
860 }
861 else if (unsortedIndex != dataColumn.Ordinal)
862 {
865 }
866 num2++;
867 }
868 bool flag6 = false;
869 DataColumn dataColumn2 = null;
870 if (chapterValue != null)
871 {
872 Type type2 = chapterValue.GetType();
874 if (dataColumn2 != null)
875 {
876 if (dataColumn2.Table == null)
877 {
882 flag6 = parentChapterColumn != null;
883 }
884 num2++;
885 }
886 }
887 if (0 < num2)
888 {
889 if (_dataSet != null && _dataTable.DataSet == null)
890 {
893 }
894 if (flag && array != null)
895 {
896 if (num < array.Length)
897 {
899 }
900 if (flag2)
901 {
903 }
904 else
905 {
906 UniqueConstraint uniqueConstraint = new UniqueConstraint("", array);
907 ConstraintCollection constraints = _dataTable.Constraints;
908 int count = constraints.Count;
909 for (int k = 0; k < count; k++)
910 {
911 if (uniqueConstraint.Equals(constraints[k]))
912 {
913 uniqueConstraint = null;
914 break;
915 }
916 }
917 if (uniqueConstraint != null)
918 {
920 }
921 }
922 }
923 if (!flag4 && !string.IsNullOrEmpty(text2) && string.IsNullOrEmpty(_dataTable.TableName))
924 {
926 }
927 if (gettingData)
928 {
932 }
933 else
934 {
935 _mappedMode = -1;
936 }
937 }
938 else
939 {
940 _dataTable = null;
941 }
942 if (flag6)
943 {
945 }
946 }
947 catch (Exception e) when (ADP.IsCatchableOrSecurityExceptionType(e))
948 {
949 RollbackAddedItems(items);
950 throw;
951 }
952 return result;
953 }
bool ICollection< KeyValuePair< TKey, TValue > >. IsReadOnly
void Add(TKey key, TValue value)
static Exception FillChapterAutoIncrement()
Definition ADP.cs:400
static InvalidOperationException MissingDataReaderFieldType(int index)
Definition ADP.cs:405
static bool IsCatchableOrSecurityExceptionType(Exception e)
Definition ADP.cs:800
DataColumn? GetDataColumn(string sourceColumn, [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields|DynamicallyAccessedMemberTypes.PublicProperties)] Type? dataType, DataTable dataTable, MissingMappingAction mappingAction, MissingSchemaAction schemaAction)
static DbSchemaRow[] GetSortedSchemaRows(DataTable dataTable, bool returnProviderSpecificTypes)
DataTableCollection Tables
Definition DataSet.cs:396
DataRowCollection Rows
Definition DataTable.cs:701
ConstraintCollection Constraints
Definition DataTable.cs:332
DataColumnCollection Columns
Definition DataTable.cs:327
object[] SetupMapping(int count, DataColumnCollection columnCollection, DataColumn chapterColumn, object chapterValue)
readonly DataReaderContainer _dataReader
void RollbackAddedItems(List< object > items)
void AddItemToAllowRollback(ref List< object > items, object value)
DataColumn[] ResizeColumnArray(DataColumn[] rgcol, int len)
readonly DataTableMapping _tableMapping
int[] CreateIndexMap(int count, int index)
void AddAdditionalProperties(DataColumn targetColumn, DataRow schemaRow)
void AddRelation(DataColumn parentChapterColumn, DataColumn chapterColumn)

References System.Data.ProviderBase.SchemaMapping._chapterMap, System.Data.ProviderBase.SchemaMapping._dataReader, System.Data.ProviderBase.SchemaMapping._dataSet, System.Data.ProviderBase.SchemaMapping._dataTable, System.Data.ProviderBase.SchemaMapping._fieldNames, System.Data.ProviderBase.SchemaMapping._indexMap, System.Data.ProviderBase.SchemaMapping._loadOption, System.Data.ProviderBase.SchemaMapping._mappedMode, System.Data.ProviderBase.SchemaMapping._schemaTable, System.Data.ProviderBase.SchemaMapping._tableMapping, System.Data.ProviderBase.SchemaMapping._xmlMap, System.Data.DataTableCollection.Add(), System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.Data.ProviderBase.SchemaMapping.AddAdditionalProperties(), System.Data.ProviderBase.SchemaMapping.AddItemToAllowRollback(), System.Data.ProviderBase.SchemaMapping.AddRelation(), System.array, System.Data.DataTable.Columns, System.Data.DataTable.Constraints, System.Data.DataRowCollection.Count, System.Data.InternalDataCollectionBase.Count, System.count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, System.Data.ProviderBase.SchemaMapping.CreateIndexMap(), System.Data.DataTable.DataSet, System.Xml.Dictionary, System.Data.Common.ADP.FillChapterAutoIncrement(), System.Data.Common.DataTableMapping.GetDataColumn(), System.Data.ProviderBase.DataReaderContainer.GetFieldType(), System.Data.Common.DbSchemaRow.GetSortedSchemaRows(), System.Data.DataColumn.IsAutoIncrementType(), System.Data.Common.ADP.IsCatchableOrSecurityExceptionType(), System.Collections.Generic.Dictionary< TKey, TValue >.IsReadOnly, System.Data.Common.ADP.MissingDataReaderFieldType(), System.Data.ProviderBase.SchemaMapping.ResizeColumnArray(), System.Data.ProviderBase.DataReaderContainer.ReturnProviderSpecificTypes, System.Data.ProviderBase.SchemaMapping.RollbackAddedItems(), System.Data.DataTable.Rows, System.Data.ProviderBase.SchemaMapping.SetupMapping(), System.Data.Common.DataTableMapping.SourceTable, System.Data.DataTable.TableName, System.Data.DataSet.Tables, System.text, and System.type.

Referenced by System.Data.ProviderBase.SchemaMapping.SchemaMapping().