コード例 #1
0
 /// <inheritdoc />
 public override string GetName(int i)
 {
     WaitIfConnectingAsync().Wait();
     ThrowIfAny();
     try
     {
         return(_worker.GetName(i));
     }
     catch (Exception e)
     {
         throw new SQLiteServerException(e.Message);
     }
 }
コード例 #2
0
        /// <summary>
        /// Create a row header given the reader.
        /// Header data is data that can be used before we call Read
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="guid">The command Guid</param>
        /// <returns></returns>
        private static RowHeader BuildRowHeader(ISQLiteServerDataReaderWorker reader, string guid)
        {
            var header = new RowHeader
            {
                TableNames = new List <string>(),
                Names      = new List <string>(),
                Types      = new List <int>(),
                HasRows    = reader.HasRows,
                Guid       = guid
            };

            // get the headers.
            for (var i = 0; i < reader.FieldCount; ++i)
            {
                header.Names.Add(reader.GetName(i));
                header.TableNames.Add(reader.GetTableName(i));
                header.Types.Add((int)Field.TypeToFieldType(reader.GetFieldType(i)));
            }

            return(header);
        }
コード例 #3
0
        /// <summary>
        /// Build the row data, this assumes that read has been called already.
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        private static RowData BuildRowData(ISQLiteServerDataReaderWorker reader)
        {
            // create the row data
            var row = new RowData
            {
                Columns = new List <Field>(),
                Nulls   = new List <bool>()
            };

            // get the column if the data has been read
            if (!reader.HasRows)
            {
                return(row);
            }

            for (var i = 0; i < reader.FieldCount; ++i)
            {
                var    isNull = reader.IsDBNull(i);
                var    type   = reader.GetFieldType(i);
                object value;
                if (isNull)
                {
                    if (type == typeof(string))
                    {
                        value = null;
                    }
                    else
                    {
                        value = Activator.CreateInstance(type);
                    }
                }
                else
                {
                    value = reader.GetValue(i);
                }
                row.Columns.Add(new Field(reader.GetName(i), type, value));
                row.Nulls.Add(isNull);
            }
            return(row);
        }