[nem-en] Nullable types
Kamil Skalski
kamil.skalski at gmail.com
Sun Jan 15 20:29:49 CET 2006
2006/1/15, Kenneth Ismert <kismert at sbcglobal.net>:
> >> Well, I'm quite neutral about nullable types. I never needed
> >> them in Nemerle yet ...
> >> I believe they are useful for static contract checking.
>
> As a database app developer, I quite like the idea. Since database
> types are inherently nullable, having an equivalent type in your
> programming language makes the straightforward things straightforward.
>
Just curious. Does .NET 2.0 introduce some extension / separate API to
read nullable values from System.Data.DbCommand?
I'm myself creating an applicatin using Sqlite for DB storage and I'm
curious what is the prefered way of fetching data.
There are two common scenarios when reading data:
- through DataAdapter, e.g. filling the DataTable object with contents
of DB to show it automatically in a Windows Forms grid. In this case
my experiments show, that a result DataTable contains the specific
values (int, bool, string, etc.) if they are not null in DB and
DbNull.Value otherwise. I'm not sure what is exactly DataAdapter doing
when filling DataTable, but it does some kind of conversions
- directly from DataReader obtained after calling DbCommand's
ExecuteReader(), where we call methods like GetInt, GetString - I
didn't check what those returning value types will actually give me,
but surely it will not be the real value... So maybe there is some way
to do reader.GetNullableInt()? Or do I have to create my own functions
for converting the result of GetObject() to nullable specific values?
(well, these ones would be easy to write or even generate by macro,
but maybe there is some builtin functionality).
--
Kamil Skalski
http://nazgul.omega.pl
More information about the devel-en
mailing list