Exemplo n.º 1
0
        /// 为了节省时间, 可以调用一次 GetOrdinal, 然后将结果分配给整数变量以便在循环中使用。
        private Dictionary <int, string> Match(IDataRecord dataRecord)
        {
            Dictionary <int, string> dictionary = new Dictionary <int, string>();
            MappingInfo mappingInfo             = new MappingInfo(this.type);

            for (int i = 0; i < dataRecord.FieldCount; i++)
            {
                string columnName = dataRecord.GetName(i);

                if (mappingInfo.ContainsColumn(columnName))
                {
                    dictionary.Add(i, mappingInfo.GetPropertyName(columnName));
                }
            }

            return(dictionary);
        }