FromDbFormat() public static method

public static FromDbFormat ( Type type, object value ) : object
type System.Type
value object
return object
コード例 #1
0
ファイル: Sqlite.cs プロジェクト: f-spot/f-spot-xplat
        internal static object GetAs(object o, Type type)
        {
            if (o != null && o.GetType() == type)
            {
                return(o);
            }

            if (o == null)
            {
                o = null;
            }
            else if (type == typeof(int))
            {
                o = (int)(long)o;
            }
            else if (type == typeof(uint))
            {
                o = (uint)(long)o;
            }
            else if (type == typeof(ulong))
            {
                o = (ulong)(long)o;
            }
            else if (type == typeof(float))
            {
                o = (float)(double)o;
            }

            if (o != null && o.GetType() == type)
            {
                return(o);
            }

            return(SqliteUtils.FromDbFormat(type, o));
        }
コード例 #2
0
ファイル: Sqlite.cs プロジェクト: f-spot/f-spot-xplat
 public T Query <T> ()
 {
     Reset();
     using (reader) {
         return(reader.Read() ? reader.Get <T> (0) : (T)SqliteUtils.FromDbFormat <T> (null));
     }
 }
コード例 #3
0
        public void SetValue(object target, IDataReader reader, int column)
        {
            // FIXME should we insist on nullable types?
            object value = reader.IsDBNull(column) ? null : reader.GetValue(column);

            SetValue(target, SqliteUtils.FromDbFormat(type, value));
        }
コード例 #4
0
ファイル: HyenaSqliteConnection.cs プロジェクト: knocte/hyena
        public T Query <T> (HyenaSqliteCommand command, params object [] param_values)
        {
            command.CommandType = HyenaCommandType.Scalar;
            QueueCommand(command, param_values);
            object result = command.WaitForResult(this);

            return((T)SqliteUtils.FromDbFormat(typeof(T), result));
        }
コード例 #5
0
 public T Get <T> (int i)
 {
     if (!read)
     {
         Read();
     }
     return((T)SqliteUtils.FromDbFormat(typeof(T), reader[i]));
 }
コード例 #6
0
        public IEnumerable <T> QueryEnumerable <T> (HyenaSqliteCommand command, params object [] param_values)
        {
            Type type = typeof(T);

            using (IDataReader reader = Query(command, param_values)) {
                while (reader.Read())
                {
                    yield return((T)SqliteUtils.FromDbFormat(type, reader[0]));
                }
            }
        }