コード例 #1
0
ファイル: SQLite3.cs プロジェクト: bdcliang/BD
        internal override object GetValue(SQLiteStatement stmt, int index, SQLiteType typ)
        {
            if (this.IsNull(stmt, index))
            {
                return(DBNull.Value);
            }
            TypeAffinity affinity = typ.Affinity;
            Type         type     = null;

            if (typ.Type != DbType.Object)
            {
                type     = SQLiteConvert.SQLiteTypeToType(typ);
                affinity = SQLiteConvert.TypeToAffinity(type);
            }
            switch (affinity)
            {
            case TypeAffinity.Int64:
                if (type != null)
                {
                    return(Convert.ChangeType(this.GetInt64(stmt, index), type, null));
                }
                return(this.GetInt64(stmt, index));

            case TypeAffinity.Double:
                if (type != null)
                {
                    return(Convert.ChangeType(this.GetDouble(stmt, index), type, null));
                }
                return(this.GetDouble(stmt, index));

            case TypeAffinity.Blob:
                if ((typ.Type != DbType.Guid) || (typ.Affinity != TypeAffinity.Text))
                {
                    int    nLength = (int)this.GetBytes(stmt, index, 0, null, 0, 0);
                    byte[] bDest   = new byte[nLength];
                    this.GetBytes(stmt, index, 0, bDest, 0, nLength);
                    if ((typ.Type == DbType.Guid) && (nLength == 0x10))
                    {
                        return(new Guid(bDest));
                    }
                    return(bDest);
                }
                return(new Guid(this.GetText(stmt, index)));

            case TypeAffinity.DateTime:
                return(this.GetDateTime(stmt, index));
            }
            return(this.GetText(stmt, index));
        }