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


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

Re: Nullable, Nothing e DbNull

Newsgroups it.comp.lang.visual-basic
Date 2016-07-08 06:37 -0700
References <18zz0guloncxb.1706r1jgpo62$.dlg@40tude.net> <0fd0ca21-9ad7-47fe-8f25-819d79ef0807@googlegroups.com> <16g50wy9x7zez$.1jdjw78l5obg2$.dlg@40tude.net>
Message-ID <dc0e9d27-0fc7-48fb-a429-9526d5a153a8@googlegroups.com> (permalink)
Subject Re: Nullable, Nothing e DbNull
From Antologiko <antologiko@gmail.com>

Show all headers | 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