Basit Khan

Basit Khan

  • 1.3k
  • 336
  • 114.7k

In .net Property of get/set how to call inside function

Sep 27 2016 3:56 AM
Hi,
 
Im using property in .net set/get
 
below is the code
 
Public Class MyDataItem
Public m_EmployeeID As Integer
Public Property EmployeeID() As Integer
Get
Return m_EmployeeID
End Get
Set(ByVal value As Integer)
m_EmployeeID = value
End Set
End Property
Private m_LastName As String
Public Property LastName() As String
Get
Return m_LastName
End Get
Set(ByVal value As String)
m_LastName = value
End Set
End Property
Private m_ImageUrl As String
Public Property ImageUrl() As String
Get
Return m_ImageUrl
End Get
Set(ByVal value As String)
m_ImageUrl = value
End Set
End Property
End Class
 
Now im using in function
 
Private Function GetDataSource() As List(Of MyDataItem)
Dim EmployeeID As Integer
Dim dataSource As New List(Of MyDataItem)()
Using connection As OleDbConnection = GetConnection()
Dim command As New OleDbCommand(String.Empty, connection)
command.CommandText = "SELECT [EmployeeID], [LastName], [Photo] FROM [Employees]"
connection.Open()
Dim reader As OleDbDataReader = command.ExecuteReader()
While reader.Read()
dataSource.Add(New MyDataItem() With { _
//how to call here EmployeeID = CInt(reader("EmployeeID")), _
//how to call here LastName = DirectCast(reader("LastName"), String), _
//how to call here ImageUrl = GetImageUrl(CInt(reader("EmployeeID")), ConvertOleObjectToByteArray(reader("Photo"))) _
})
End While
End Using
Return dataSource
End Function
 
 
Thanks
Basit. 

Answers (1)