Exemplo n.º 1
0
 private void BuildResultType()
 {
     if (!string.IsNullOrEmpty(ResolvedConnectionString) && !string.IsNullOrEmpty(ResolvedSqlStatementValue))
     {
         string    designTimeSql = SqlStringHandler.GetSqlStringHandler(ResolvedSqlStatementValue).GetExecutableDesignTimeSql();
         DataTable schema        = null;
         try
         {
             schema = DatabaseHelpers.RetrieveSchema(ConnectionType, ResolvedConnectionString, designTimeSql);
         }
         catch { }
         if (schema != null)
         {
             var resultFields            = ResultTypeValue.Fields;
             ResultTypeFields newResults = BuildResultType(schema, resultFields);
             resultFields.Clear();
             foreach (ResultTypeField nextField in newResults)
             {
                 resultFields.Add(nextField);
             }
         }
     }
     BuildDataOut();
     BuildExecutionPaths();
 }
Exemplo n.º 2
0
        private IDbCommand CreateCommand()
        {
            IDbCommand command;

            if (transaction == null)
            {
                command = DatabaseHelpers.CreateCommand(connectionType, connectionString, sql, sqlValues, timeout);
                LogCommand(command);
                Log(string.Format("Opening connection <{0}>", connectionString));
                command.Connection.Open();
                Log("Opened connection.");
            }
            else
            {
                command = DatabaseHelpers.CreateCommand(connectionType, transaction.Connection, sql, sqlValues, timeout);
                LogCommand(command);
                command.Transaction = transaction;
            }
            return(command);
        }
Exemplo n.º 3
0
        public static ResultTypeFields BuildResultType(DataTable dataTable, ResultTypeFields reusableFields = null)
        {
            ResultTypeFields resultFields = new ResultTypeFields();

            foreach (DataColumn dataColumn in dataTable.Columns)
            {
                var oldModel = reusableFields == null ? null : reusableFields.FirstOrDefault(x => x.ColumnName == dataColumn.ColumnName);
                if (oldModel == null)
                {
                    ResultTypeField newModel = new ResultTypeField();
                    newModel.ColumnName = dataColumn.ColumnName;
                    newModel.Name       = DatabaseHelpers.GetValidName(dataColumn.ColumnName);
                    newModel.Type       = MapResultType(dataColumn.DataType);
                    resultFields.Add(newModel);
                }
                else
                {
                    resultFields.Add(oldModel);
                }
            }
            return(resultFields);
        }