System.Data.ProviderBase.SchemaMapping.LoadDataRow C# (CSharp) Method

LoadDataRow() private method

private LoadDataRow ( ) : void
return void
        internal void LoadDataRow()
        {
            try
            {
                _dataReader.GetValues(_readerDataValues);
                object[] mapped = GetMappedValues();

                DataRow dataRow;
                switch (_loadOption)
                {
                    case LoadOption.OverwriteChanges:
                    case LoadOption.PreserveChanges:
                    case LoadOption.Upsert:
                        dataRow = _dataTable.LoadDataRow(mapped, _loadOption);
                        break;
                    case (LoadOption)4: // true
                        dataRow = _dataTable.LoadDataRow(mapped, true);
                        break;
                    case (LoadOption)5: // false
                        dataRow = _dataTable.LoadDataRow(mapped, false);
                        break;
                    default:
                        Debug.Assert(false, "unexpected LoadOption");
                        throw ADP.InvalidLoadOption(_loadOption);
                }
                if ((null != _chapterMap) && (null != _dataSet))
                {
                    LoadDataRowChapters(dataRow);
                }
            }
            finally
            {
                if (null != _chapterMap)
                {
                    FreeDataRowChapters();
                }
            }
        }

Usage Example

 private int FillLoadDataRow(SchemaMapping mapping) {
     int rowsAddedToDataSet = 0;
     DataReaderContainer dataReader = mapping.DataReader;
     if (_hasFillErrorHandler) {
         while (dataReader.Read()) { // read remaining rows of first and subsequent resultsets
             try {
                 // only try-catch if a FillErrorEventHandler is registered so that
                 // in the default case we get the full callstack from users
                 mapping.LoadDataRowWithClear();
                 rowsAddedToDataSet++;
             }
             catch(Exception e) {
                 // 
                 if (!ADP.IsCatchableExceptionType(e)) {
                     throw;
                 }                    
                 ADP.TraceExceptionForCapture(e);
                 OnFillErrorHandler(e, mapping.DataTable, mapping.DataValues);
             }
         }
     }
     else {
         while (dataReader.Read()) { // read remaining rows of first and subsequent resultset
             mapping.LoadDataRow();
             rowsAddedToDataSet++;
         }
     }
     return rowsAddedToDataSet;
 }
All Usage Examples Of System.Data.ProviderBase.SchemaMapping::LoadDataRow