Language: Add Datatable.First Extension method
This commit is contained in:
parent
24f4051b1c
commit
9deeec86e4
@ -1,6 +1,6 @@
|
|||||||
Imports System.Runtime.CompilerServices
|
Imports System.Runtime.CompilerServices
|
||||||
|
|
||||||
Public Module DataRowEx
|
Public Module DataTableEx
|
||||||
<Extension()>
|
<Extension()>
|
||||||
Public Function ItemEx(Of T)(pRow As DataRow, pFieldName As String, Optional pDefaultValue As T = Nothing) As T
|
Public Function ItemEx(Of T)(pRow As DataRow, pFieldName As String, Optional pDefaultValue As T = Nothing) As T
|
||||||
Try
|
Try
|
||||||
@ -9,4 +9,16 @@ Public Module DataRowEx
|
|||||||
Return Nothing
|
Return Nothing
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
<Extension()>
|
||||||
|
Public Function First(pTable As DataTable) As DataRow
|
||||||
|
Try
|
||||||
|
If pTable Is Nothing OrElse pTable.Rows.Count = 0 Then
|
||||||
|
Return Nothing
|
||||||
|
End If
|
||||||
|
Return pTable.Rows.Item(0)
|
||||||
|
Catch ex As Exception
|
||||||
|
Return Nothing
|
||||||
|
End Try
|
||||||
|
End Function
|
||||||
End Module
|
End Module
|
||||||
@ -74,7 +74,7 @@
|
|||||||
<Import Include="System.Threading.Tasks" />
|
<Import Include="System.Threading.Tasks" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="DataRowEx.vb" />
|
<Compile Include="DataTableEx.vb" />
|
||||||
<Compile Include="InvalidChars.vb" />
|
<Compile Include="InvalidChars.vb" />
|
||||||
<Compile Include="Utils.vb" />
|
<Compile Include="Utils.vb" />
|
||||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user