Imports System
Imports System.Data
Imports System.Data.Common
Namespace DotNetDataProviderTemplate
Public Class TemplateDataAdapter
Inherits DbDataAdapter
Implements IDbDataAdapter
Private m_selectCommand As TemplateCommand
Private m_insertCommand As TemplateCommand
Private m_updateCommand As TemplateCommand
Private m_deleteCommand As TemplateCommand
'*
'* Inherit from Component through DbDataAdapter. The event
'* mechanism is designed to work with the Component.Events
'* property. These variables are the keys used to find the
'* events in the components list of events.
'*
Private Shared ReadOnly EventRowUpdated As Object = New Object()
Private Shared ReadOnly EventRowUpdating As Object = New Object()
Public Sub New()
MyBase.New
End Sub
Property IDbDataAdapterSelectCommand As IDbCommand Implements IDbDataAdapter.SelectCommand
Get
Return m_selectCommand
End Get
Set
m_selectCommand = CType(value, TemplateCommand)
End Set
End Property
Public Property SelectCommand As TemplateCommand
Get
Return m_selectCommand
End Get
Set
m_selectCommand = value
End Set
End Property
Property IDbDataAdapterInsertCommand As IDbCommand Implements IDbDataAdapter.InsertCommand
Get
Return m_insertCommand
End Get
Set
m_insertCommand = CType(value, TemplateCommand)
End Set
End Property
Public Property InsertCommand As TemplateCommand
Get
Return m_insertCommand
End Get
Set
m_insertCommand = value
End Set
End Property
Property IDbDataAdapterUpdateCommand As IDbCommand Implements IDbDataAdapter.UpdateCommand
Get
Return m_updateCommand
End Get
Set
m_updateCommand = CType(value, TemplateCommand)
End Set
End Property
Public Property UpdateCommand As TemplateCommand
Get
Return m_updateCommand
End Get
Set
m_updateCommand = value
End Set
End Property
Property IDbDataAdapterDeleteCommand As IDbCommand Implements IDbDataAdapter.DeleteCommand
Get
Return m_deleteCommand
End Get
Set
m_deleteCommand = CType(value, TemplateCommand)
End Set
End Property
Public Property DeleteCommand As TemplateCommand
Get
Return m_deleteCommand
End Get
Set
m_deleteCommand = value
End Set
End Property
'*
'* Implement abstract methods inherited from DbDataAdapter.
'*
Protected Overrides Function CreateRowUpdatedEvent(dataRow As DataRow, command As IDbCommand, statementType As StatementType, tableMapping As DataTableMapping) As RowUpdatedEventArgs
Return New TemplateRowUpdatedEventArgs(dataRow, command, statementType, tableMapping)
End Function
Protected Overrides Function CreateRowUpdatingEvent(dataRow As DataRow, command As IDbCommand, statementType As StatementType, tableMapping As DataTableMapping) As RowUpdatingEventArgs
Return New TemplateRowUpdatingEventArgs(dataRow, command, statementType, tableMapping)
End Function
Protected Overrides Sub OnRowUpdating(value As RowUpdatingEventArgs)
Dim handler As TemplateRowUpdatingEventHandler = CType(Events(EventRowUpdating), TemplateRowUpdatingEventHandler)
If Not handler Is Nothing And value.GetType() Is Type.GetType("TemplateRowUpdatingEventArgs") Then
handler(Me, CType(value, TemplateRowUpdatingEventArgs))
End If
End Sub
Protected Overrides Sub OnRowUpdated(value As RowUpdatedEventArgs)
Dim handler As TemplateRowUpdatedEventHandler = CType(Events(EventRowUpdated), TemplateRowUpdatedEventHandler)
If Not handler Is Nothing And value.GetType() Is Type.GetType("TemplateRowUpdatedEventArgs") Then
handler(Me, CType(value, TemplateRowUpdatedEventArgs))
End If
End Sub
Public Event RowUpdating As TemplateRowUpdatingEventHandler
Public Event RowUpdated As TemplateRowUpdatedEventHandler
End Class
Public Delegate Sub TemplateRowUpdatingEventHandler(sender As Object, e As TemplateRowUpdatingEventArgs)
Public Delegate Sub TemplateRowUpdatedEventHandler(sender As Object, e As TemplateRowUpdatedEventArgs)
Public Class TemplateRowUpdatingEventArgs
Inherits RowUpdatingEventArgs
Public Sub New(row As DataRow, command As IDbCommand, statementType As StatementType, tableMapping As DataTableMapping)
MyBase.New(row, command, statementType, tableMapping)
End Sub
' Hide the inherited implementation of the command property.
Public Shadows Property Command As TemplateCommand
Get
Return CType(MyBase.Command, TemplateCommand)
End Get
Set
MyBase.Command = value
End Set
End Property
End Class
Public Class TemplateRowUpdatedEventArgs
Inherits RowUpdatedEventArgs
Public Sub New(row As DataRow, command As IDbCommand, statementType As StatementType, tableMapping As DataTableMapping)
MyBase.New(row, command, statementType, tableMapping)
End Sub
' Hide the inherited implementation of the command property.
Public Shadows ReadOnly Property Command As TemplateCommand
Get
Return CType(MyBase.Command, TemplateCommand)
End Get
End Property
End Class
End Namespace