> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of Random Coder
> 
> Could you not do something like this to handle the nullable types?
> 
>     T GetValue<T>(string field)
>     {
>         object obj = reader[field];
> 
>         if (obj is System.DBNull)
>             return default(T);
>         else
>             return (T)obj;
>     }
> 
> Assuming the type is nullable, it should do the right thing, and if it's an
> unexpected type, it'll throw an exception when casting to T.

In fact, that's what I'm doing now - except I decided to make it specifically 
long, string, and byte[], rather than generic.  Because I wanted to discourage 
any sort of belief of actual support for things like int, uint16, uint64, etc.  
All of which would technically work except ulong (uint64)...

If this is the way people use it, so be it.  I just thought there would 
probably exist something more natural, that I couldn't find...
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to