/// <inheritdoc />
 public override object GetValue(int i)
 {
     WaitIfConnectingAsync().Wait();
     ThrowIfAny();
     try
     {
         return(_worker.GetValue(i));
     }
     catch (Exception e)
     {
         throw new SQLiteServerException(e.Message);
     }
 }
Beispiel #2
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);
        }