Пример #1
0
 private void DefineActions(SqlTask sqlT, List <string> columnNames)
 {
     if (columnNames?.Count == 0 && (TypeInfo.IsArray || TypeInfo.PropertyNames.Count == 0))
     {
         throw new ETLBoxException("The column names can't be automatically retrieved - please provide a TableDefinition with names for the columns in the source.");
     }
     _row = default(TOutput);
     if (TypeInfo.IsArray)
     {
         sqlT.BeforeRowReadAction               = () =>
                                           _row = (TOutput)Activator.CreateInstance(typeof(TOutput), new object[] { columnNames.Count });
         int index = 0;
         foreach (var colName in columnNames)
         {
             index = SetupArrayFillAction(sqlT, index);
         }
     }
     else
     {
         if (columnNames?.Count == 0)
         {
             columnNames = TypeInfo.PropertyNames;
         }
         foreach (var colName in columnNames)
         {
             if (TypeInfo.HasPropertyOrColumnMapping(colName))
             {
                 SetupObjectFillAction(sqlT, colName);
             }
             else if (TypeInfo.IsDynamic)
             {
                 SetupDynamicObjectFillAction(sqlT, colName);
             }
             else
             {
                 sqlT.Actions.Add(col => { });
             }
         }
         sqlT.BeforeRowReadAction = () => _row = (TOutput)Activator.CreateInstance(typeof(TOutput));
     }
     sqlT.AfterRowReadAction = () =>
     {
         if (_row != null)
         {
             LogProgress();
             DbConnectionManager.CheckLicenseOrThrow(ProgressCount);
             if (!Buffer.SendAsync(_row).Result)
             {
                 throw new ETLBoxException("Buffer already completed or faulted!", this.Exception);
             }
         }
     };
 }
Пример #2
0
 internal void DefineActions(SqlTask sqlT, List <string> columnNames)
 {
     _row = default(TOutput);
     if (TypeInfo.IsArray)
     {
         sqlT.BeforeRowReadAction               = () =>
                                           _row = (TOutput)Activator.CreateInstance(typeof(TOutput), new object[] { columnNames.Count });
         int index = 0;
         foreach (var colName in columnNames)
         {
             index = SetupArrayFillAction(sqlT, index);
         }
     }
     else
     {
         if (columnNames?.Count == 0)
         {
             columnNames = TypeInfo.PropertyNames;
         }
         foreach (var colName in columnNames)
         {
             if (TypeInfo.HasPropertyOrColumnMapping(colName))
             {
                 SetupObjectFillAction(sqlT, colName);
             }
             else if (TypeInfo.IsDynamic)
             {
                 SetupDynamicObjectFillAction(sqlT, colName);
             }
             else
             {
                 sqlT.Actions.Add(col => { });
             }
         }
         sqlT.BeforeRowReadAction = () => _row = (TOutput)Activator.CreateInstance(typeof(TOutput));
     }
     sqlT.AfterRowReadAction = () =>
     {
         if (_row != null)
         {
             LogProgress();
             DbConnectionManager.CheckLicenseOrThrow(ProgressCount);
             Buffer.SendAsync(_row).Wait();
         }
     };
 }