コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DqlDataAdapter" /> class.
 /// </summary>
 /// <param name="selectCommandText">The select command text.</param>
 /// <param name="selectConnection">The select connection.</param>
 public DqlDataAdapter(string selectCommandText, DqlConnection selectConnection)
 {
     this.command = new DqlCommand(selectCommandText, selectConnection)
     {
         CommandText = selectCommandText,
         CommandType = CommandType.Text
     };
 }
コード例 #2
0
        /// <summary>
        /// Fills the specified data set.
        /// </summary>
        /// <param name="dataSet">The data set.</param>
        /// <param name="token">The token.</param>
        /// <returns>System.Int32.</returns>
        public int Fill(DataSet dataSet, CancellationToken token)
        {
            DqlReader formatter = new DqlReader();

            List <DqlCommand> commands = new List <DqlCommand>();

            command.CommandText.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)
            .ToList().Where(w => string.IsNullOrEmpty(w) == false).ToList()
            .ForEach(commandText => commands.Add(new DqlCommand(commandText, (DqlConnection)command.Connection)));

            foreach (var cmd in commands)
            {
                if (token.IsCancellationRequested)
                {
                    throw new OperationCanceledException("A cancellation token associated with this operation was canceled");
                }

                DqlConnection cn = cmd.Connection;
                if (cn == null)
                {
                    throw new Exception("Connection is null");
                }

                IDfCollection  records  = cn.ExecuteQuery(cmd);
                DataTable      table    = null;
                IDfTypedObject typedObj = null;
                #region Row Iterator
                while (records.next())
                {
                    if (token.IsCancellationRequested)
                    {
                        throw new OperationCanceledException("A cancellation token associated with this operation was canceled");
                    }

                    CreateTable(ref table, records);
                    typedObj = records.getTypedObject();

                    DataRow row = table.NewRow();
                    table.Rows.Add(row);

                    #region Column Iterator
                    int count = records.getAttrCount();
                    for (int i = 0; i < count; i++)
                    {
                        var     collection = records;
                        IDfAttr attr       = collection.getAttr(i);
                        string  field      = attr.getName();

                        if (formatter.ContainsKey((tagDfValueTypes)attr.getDataType()))
                        {
                            row[field] = formatter[(tagDfValueTypes)attr.getDataType()](attr, collection);
                        }
                    }
                    #endregion
                }
                #endregion

                records.close();
                records = null; typedObj = null;

                if (table != null)
                {
                    dataSet.Tables.Add(table);
                }
            }

            commands.ForEach(item => item.Dispose());

            return(1);
        }