I converted some code from c# for a VB.net project
I have an object declared as this :
here is the extention method i am trying to call
now my problem is this on my call vb expects me to pass an object that implements IDatarecord however c# does not here is my call to the extention method
I get the error Error 7 Argument not specified for parameter 'record' of 'Public Shared Function Create(record As System.Data.IDataRecord) As oUserApplication'. C:\VisualStudio\SourceControl\Replatform\WebServices\UserWS\UserWS\ProcessUser.vb 1117 77 UserWS any ideas ?
I have an object declared as this :
VB.NET:
<Serializable()> _
Public Class oUserApplication
Public ApplicationID As Integer = 0
Public ApplicationRoleID As Integer = 0
Public RoleID As UserRoles = UserRoles.Unknown
Public DefaultFlag As Boolean = False
Public Found As Boolean = False 'updated on UI side not from DB
Public ApplicationDescription As String = ""
Public RoleDescription As String = ""
Public LastUpdateUser As String = ""
Public LastUpdateDate As Date = Date.MinValue
'TO DO figure out what to do with descriptions
Public Shared Function Create(record As IDataRecord) As oUserApplication
Return New oUserApplication With { _
.ApplicationID = record("ApplicationID"),
.ApplicationRoleID = record("ApplicationRoleID"),
.DefaultFlag = record("DefaultFlag"),
.LastUpdateUser = record("sysUpdateUser"),
.LastUpdateDate = record("sysUpdateDate")
}
End Function
End Class
here is the extention method i am trying to call
VB.NET:
<System.Runtime.CompilerServices.Extension()> _
Public Function GetData(Of T)(reader As IDataReader, BuildObject As Func(Of IDataRecord, T)) As IEnumerable(Of T)
Try
While reader.Read()
Return BuildObject(reader)
End While
Finally
reader.Dispose()
End Try
Return Nothing
End Function
VB.NET:
Dim result = Myextentions.GetData(Of oUserApplicationoUser)(oRD, oUserApplicationoUser.Create)