Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > it.comp.lang.visual-basic > #18839

Re: Nullable, Nothing e DbNull

X-Received by 10.237.35.61 with SMTP id h58mr4909230qtc.3.1467985064488; Fri, 08 Jul 2016 06:37:44 -0700 (PDT)
X-Received by 10.36.242.65 with SMTP id j62mr142268ith.8.1467985064402; Fri, 08 Jul 2016 06:37:44 -0700 (PDT)
Path csiph.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!f89no3444888qtd.0!news-out.google.com!d68ni579ith.0!nntp.google.com!r1no13968347ige.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups it.comp.lang.visual-basic
Date Fri, 8 Jul 2016 06:37:43 -0700 (PDT)
In-Reply-To <16g50wy9x7zez$.1jdjw78l5obg2$.dlg@40tude.net>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=188.219.188.62; posting-account=4c3DWgoAAADQcJJevo-GlQ6CVmV90H2x
NNTP-Posting-Host 188.219.188.62
References <18zz0guloncxb.1706r1jgpo62$.dlg@40tude.net> <0fd0ca21-9ad7-47fe-8f25-819d79ef0807@googlegroups.com> <16g50wy9x7zez$.1jdjw78l5obg2$.dlg@40tude.net>
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <dc0e9d27-0fc7-48fb-a429-9526d5a153a8@googlegroups.com> (permalink)
Subject Re: Nullable, Nothing e DbNull
From Antologiko <antologiko@gmail.com>
Injection-Date Fri, 08 Jul 2016 13:37:44 +0000
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Lines 25
Xref csiph.com it.comp.lang.visual-basic:18839

Show key headers only | View raw


> Apparte questa cosa che comunque ho risolto, mi chiedevo se si poteva fare
> qualche extension in modo da poter fare tipo
> 
> p.DataDimissione=dr.GetNullableDateTime(9)
> Se nel DB c'è Dbnull.Value mi assegna nothing, altrimenti il valore.
> 
> Lo stesso problema c'è con tutti i tipi Value.


Secondo me si.

Imports System.Runtime.CompilerServices

Module IDataReaderExtensions

    <Extension()> 
    Public Function GetNullableDate(ByVal DR As IDataReader, Column As Integer) As Nullable(Of Date)
        If
            DR.IsDBNull(Column) Then GetNullableDate = Nothing
        Else
            GetNullableDate = DR.GetDateTime(Column)
        End If
    End Sub
End Module

Back to it.comp.lang.visual-basic | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Nullable, Nothing e DbNull "Andrea (Work)" <andrea.isworkDELETEME@gmail.invalid> - 2016-07-06 12:25 +0200
  Nullable, Nothing e DbNull Antologiko <antologiko@gmail.com> - 2016-07-06 07:59 -0700
    Re: Nullable, Nothing e DbNull "Andrea (Work)" <andrea.isworkDELETEME@gmail.invalid> - 2016-07-08 11:41 +0200
      Re: Nullable, Nothing e DbNull Antologiko <antologiko@gmail.com> - 2016-07-08 06:37 -0700
        Re: Nullable, Nothing e DbNull "Andrea (Work)" <andrea.isworkDELETEME@gmail.invalid> - 2016-07-13 08:47 +0200

csiph-web