' <fileinfo name="CustomerCustomerDemoCollection_Base.vb">
' <copyright>
' All rights reserved.
' </copyright>
' <remarks>
' Do not change this source code manually. Changes to this file may
' cause incorrect behavior and will be lost if the code is regenerated.
' </remarks>
' <generator rewritefile="True" infourl="http://www.SharpPower.com">RapTier</generator>
' </fileinfo>
Option Strict Off
Option Explicit On
Imports System
Imports System.Data
''' <summary>
''' The base class for <see cref="CustomerCustomerDemoCollection"/>. Provides methods
''' for common database table operations.
''' </summary>
''' <remarks>
''' Do not change this source code. Update the <see cref="CustomerCustomerDemoCollection"/>
''' class if you need to add or change some functionality.
''' </remarks>
Public MustInherit Class CustomerCustomerDemoCollection_Base
' Constants
Public Const CustomerIDColumnName As String = "CustomerID"
Public Const CustomerTypeIDColumnName As String = "CustomerTypeID"
' Instance fields
Private _db As Northwind
''' <summary>
''' Initializes a new instance of the <see cref="CustomerCustomerDemoCollection_Base"/>
''' class with the specified <see cref="Northwind"/>.
''' </summary>
''' <param name="db">The <see cref="Northwind"/> object.</param>
Public Sub New(db As Northwind)
MyBase.New()
_db = db
End Sub
''' <summary>
''' Gets the database object that this table belongs to.
''' </summary>
''' <value>The <see cref="Northwind"/> object.</value>
Protected ReadOnly Property Database As Northwind
Get
Return _db
End Get
End Property
''' <summary>
''' Gets an array of all records from the <c>CustomerCustomerDemo</c> table.
''' </summary>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Public Overridable Function GetAll() As CustomerCustomerDemoRow()
Return MapRecords(CreateGetAllCommand())
End Function
''' <summary>
''' Gets a <see cref="System.Data.DataTable"/> object that
''' includes all records from the <c>CustomerCustomerDemo</c> table.
''' </summary>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Public Overridable Function GetAllAsDataTable() As DataTable
Return MapRecordsToDataTable(CreateGetAllCommand())
End Function
''' <summary>
''' Creates and returns an <see cref="System.Data.IDbCommand"/> object that is used
''' to retrieve all records from the <c>CustomerCustomerDemo</c> table.
''' </summary>
''' <returns>A reference to the <see cref="System.Data.IDbCommand"/> object.</returns>
Protected Overridable Function CreateGetAllCommand() As IDbCommand
Return _db.CreateCommand("dbo._CustomerCustomerDemo_GetAll", True)
End Function
''' <summary>
''' Gets the first <see cref="CustomerCustomerDemoRow"/> objects that
''' match the search condition.
''' </summary>
''' <param name="whereSql">The SQL search condition. For example:
''' <c>"FirstName='Smith' AND Zip=75038"</c>.</param>
''' <returns>An instance of <see cref="CustomerCustomerDemoRow"/> or null reference
''' (Nothing in Visual Basic) if the object was not found.</returns>
Public Function GetRow(whereSql As String) As CustomerCustomerDemoRow
Dim totalRecordCount As Integer = -1
Dim rows As CustomerCustomerDemoRow() = GetAsArray(whereSql, Nothing, 0, 1, totalRecordCount)
If 0 = rows.Length Then
Return Nothing
End If
Return rows(0)
End Function
''' <summary>
''' Gets an array of <see cref="CustomerCustomerDemoRow"/> objects that
''' match the search condition, in the the specified sort order.
''' </summary>
''' <param name="whereSql">The SQL search condition. For example:
''' <c>"FirstName='Smith' AND Zip=75038"</c>.</param>
''' <param name="orderBySql">The column name(s) followed by "ASC" (ascending) or "DESC" (descending).
''' Columns are sorted in ascending order by default. For example: <c>"LastName ASC, FirstName ASC"</c>.</param>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Public Function GetAsArray(whereSql As String, orderBySql As String) As CustomerCustomerDemoRow()
Dim totalRecordCount As Integer = -1
Return GetAsArray(whereSql, orderBySql, 0, Integer.MaxValue, totalRecordCount)
End Function
''' <summary>
''' Gets an array of <see cref="CustomerCustomerDemoRow"/> objects that
''' match the search condition, in the the specified sort order.
''' </summary>
''' <param name="whereSql">The SQL search condition. For example:
''' <c>"FirstName='Smith' AND Zip=75038"</c>.</param>
''' <param name="orderBySql">The column name(s) followed by "ASC" (ascending) or "DESC" (descending).
''' Columns are sorted in ascending order by default. For example: <c>"LastName ASC, FirstName ASC"</c>.</param>
''' <param name="startIndex">The index of the first record to return.</param>
''' <param name="length">The number of records to return.</param>
''' <param name="totalRecordCount">A reference parameter that returns the total number
''' of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Public Overridable Function GetAsArray(whereSql As String, orderBySql As String, _
startIndex As Integer, length As Integer, _
ByRef totalRecordCount As Integer) As CustomerCustomerDemoRow()
Dim reader As IDataReader = _db.ExecuteReader(CreateGetCommand(whereSql, orderBySql))
Try
Return MapRecords(reader, startIndex, length, totalRecordCount)
Finally
reader.Dispose()
End Try
End Function
''' <summary>
''' Gets a <see cref="System.Data.DataTable"/> object filled with data that
''' match the search condition, in the the specified sort order.
''' </summary>
''' <param name="whereSql">The SQL search condition. For example: "FirstName='Smith' AND Zip=75038".</param>
''' <param name="orderBySql">The column name(s) followed by "ASC" (ascending) or "DESC" (descending).
''' Columns are sorted in ascending order by default. For example: "LastName ASC, FirstName ASC".</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Public Function GetAsDataTable(whereSql As String, orderBySql As String) As DataTable
Dim totalRecordCount As Integer = -1
return GetAsDataTable(whereSql, orderBySql, 0, Integer.MaxValue, totalRecordCount)
End Function
''' <summary>
''' Gets a <see cref="System.Data.DataTable"/> object filled with data that
''' match the search condition, in the the specified sort order.
''' </summary>
''' <param name="whereSql">The SQL search condition. For example: "FirstName='Smith' AND Zip=75038".</param>
''' <param name="orderBySql">The column name(s) followed by "ASC" (ascending) or "DESC" (descending).
''' Columns are sorted in ascending order by default. For example: "LastName ASC, FirstName ASC".</param>
''' <param name="startIndex">The index of the first record to return.</param>
''' <param name="length">The number of records to return.</param>
''' <param name="totalRecordCount">A reference parameter that returns the total number
''' of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Public Overridable Function GetAsDataTable(whereSql As String, orderBySql As String, _
startIndex As Integer, length As Integer, _
ByRef totalRecordCount As Integer) As DataTable
Dim reader As IDataReader = _db.ExecuteReader(CreateGetCommand(whereSql, orderBySql))
Try
Return MapRecordsToDataTable(reader, startIndex, length, totalRecordCount)
Finally
reader.Dispose()
End Try
End Function
''' <summary>
''' Creates an <see cref="System.Data.IDbCommand"/> object for the specified search criteria.
''' </summary>
''' <param name="whereSql">The SQL search condition. For example: "FirstName='Smith' AND Zip=75038".</param>
''' <param name="orderBySql">The column name(s) followed by "ASC" (ascending) or "DESC" (descending).
''' Columns are sorted in ascending order by default. For example: "LastName ASC, FirstName ASC".</param>
''' <returns>A reference to the <see cref="System.Data.IDbCommand"/> object.</returns>
Protected Overridable Function CreateGetCommand(whereSql As String, _
orderBySql As String) As IDbCommand
Dim sql As String = "SELECT * FROM [dbo].[CustomerCustomerDemo]"
If Not(whereSql Is Nothing) AndAlso 0 < whereSql.Length Then
sql += " WHERE " + whereSql
End If
If Not(orderBySql Is Nothing) AndAlso 0 < orderBySql.Length Then
sql += " ORDER BY " + orderBySql
End If
Return _db.CreateCommand(sql)
End Function
''' <summary>
''' Gets <see cref="CustomerCustomerDemoRow"/> by the primary key.
''' </summary>
''' <param name="customerID">The <c>CustomerID</c> column value.</param>
''' <param name="customerTypeID">The <c>CustomerTypeID</c> column value.</param>
''' <returns>An instance of <see cref="CustomerCustomerDemoRow"/> or null reference
''' (Nothing in Visual Basic) if the object was not found.</returns>
Public Overridable Function GetByPrimaryKey(customerID As String, customerTypeID As String) As CustomerCustomerDemoRow
Dim cmd As IDbCommand = _db.CreateCommand("dbo._CustomerCustomerDemo_GetByPrimaryKey", True)
AddParameter(cmd, "CustomerID", customerID)
AddParameter(cmd, "CustomerTypeID", customerTypeID)
Dim tempArray As CustomerCustomerDemoRow() = MapRecords(cmd)
If 0 = tempArray.Length Then
Return Nothing
End If
Return tempArray(0)
End Function
''' <summary>
''' Gets an array of <see cref="CustomerCustomerDemoRow"/> objects
''' by the <c>FK_CustomerCustomerDemo</c> foreign key.
''' </summary>
''' <param name="customerTypeID">The <c>CustomerTypeID</c> column value.</param>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Public Overridable Function GetByCustomerTypeID(customerTypeID As String) As CustomerCustomerDemoRow()
Return MapRecords(CreateGetByCustomerTypeIDCommand(customerTypeID))
End Function
''' <summary>
''' Gets a <see cref="System.Data.DataTable"/> object
''' by the <c>FK_CustomerCustomerDemo</c> foreign key.
''' </summary>
''' <param name="customerTypeID">The <c>CustomerTypeID</c> column value.</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Public Overridable Function GetByCustomerTypeIDAsDataTable(customerTypeID As String) As DataTable
Return MapRecordsToDataTable(CreateGetByCustomerTypeIDCommand(customerTypeID))
End Function
''' <summary>
''' Creates an <see cref="System.Data.IDbCommand"/> object that can be used to
''' return records by the <c>FK_CustomerCustomerDemo</c> foreign key.
''' </summary>
''' <param name="customerTypeID">The <c>CustomerTypeID</c> column value.</param>
''' <returns>A reference to the <see cref="System.Data.IDbCommand"/> object.</returns>
Protected Overridable Function CreateGetByCustomerTypeIDCommand( _
customerTypeID As String) As IDbCommand
Dim cmd As IDbCommand = _db.CreateCommand("dbo._CustomerCustomerDemo_GetBy_CustomerTypeID", True)
AddParameter(cmd, "CustomerTypeID", customerTypeID)
Return cmd
End Function
''' <summary>
''' Gets an array of <see cref="CustomerCustomerDemoRow"/> objects
''' by the <c>FK_CustomerCustomerDemo_Customers</c> foreign key.
''' </summary>
''' <param name="customerID">The <c>CustomerID</c> column value.</param>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Public Overridable Function GetByCustomerID(customerID As String) As CustomerCustomerDemoRow()
Return MapRecords(CreateGetByCustomerIDCommand(customerID))
End Function
''' <summary>
''' Gets a <see cref="System.Data.DataTable"/> object
''' by the <c>FK_CustomerCustomerDemo_Customers</c> foreign key.
''' </summary>
''' <param name="customerID">The <c>CustomerID</c> column value.</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Public Overridable Function GetByCustomerIDAsDataTable(customerID As String) As DataTable
Return MapRecordsToDataTable(CreateGetByCustomerIDCommand(customerID))
End Function
''' <summary>
''' Creates an <see cref="System.Data.IDbCommand"/> object that can be used to
''' return records by the <c>FK_CustomerCustomerDemo_Customers</c> foreign key.
''' </summary>
''' <param name="customerID">The <c>CustomerID</c> column value.</param>
''' <returns>A reference to the <see cref="System.Data.IDbCommand"/> object.</returns>
Protected Overridable Function CreateGetByCustomerIDCommand( _
customerID As String) As IDbCommand
Dim cmd As IDbCommand = _db.CreateCommand("dbo._CustomerCustomerDemo_GetBy_CustomerID", True)
AddParameter(cmd, "CustomerID", customerID)
Return cmd
End Function
''' <summary>
''' Adds a new record into the <c>CustomerCustomerDemo</c> table.
''' </summary>
''' <param name="value">The <see cref="CustomerCustomerDemoRow"/> object to be inserted.</param>
Public Overridable Sub Insert(value As CustomerCustomerDemoRow)
Dim cmd As IDbCommand = _db.CreateCommand("dbo._CustomerCustomerDemo_Insert", true)
AddParameter(cmd, "CustomerID", value.CustomerID)
AddParameter(cmd, "CustomerTypeID", value.CustomerTypeID)
cmd.ExecuteNonQuery()
End Sub
''' <summary>
''' Deletes the specified object from the <c>CustomerCustomerDemo</c> table.
''' </summary>
''' <param name="value">The <see cref="CustomerCustomerDemoRow"/> object to delete.</param>
''' <returns>true if the record was deleted; otherwise, false.</returns>
Public Function Delete(value As CustomerCustomerDemoRow) As Boolean
Return DeleteByPrimaryKey(value.CustomerID, value.CustomerTypeID)
End Function
''' <summary>
''' Deletes a record from the <c>CustomerCustomerDemo</c> table using
''' the specified primary key.
''' </summary>
''' <param name="customerID">The <c>CustomerID</c> column value.</param>
''' <param name="customerTypeID">The <c>CustomerTypeID</c> column value.</param>
''' <returns>true if the record was deleted; otherwise, false.</returns>
Public Overridable Function DeleteByPrimaryKey(customerID As String, customerTypeID As String) As Boolean
Dim cmd As IDbCommand = _db.CreateCommand("dbo._CustomerCustomerDemo_DeleteByPrimaryKey", true)
AddParameter(cmd, "CustomerID", customerID)
AddParameter(cmd, "CustomerTypeID", customerTypeID)
Return 0 < cmd.ExecuteNonQuery()
End Function
''' <summary>
''' Deletes records from the <c>CustomerCustomerDemo</c> table using the
''' <c>FK_CustomerCustomerDemo</c> foreign key.
''' </summary>
''' <param name="customerTypeID">The <c>CustomerTypeID</c> column value.</param>
''' <returns>The number of records deleted from the table.</returns>
Public Function DeleteByCustomerTypeID(customerTypeID As String) As Integer
Return CreateDeleteByCustomerTypeIDCommand(customerTypeID).ExecuteNonQuery()
End Function
''' <summary>
''' Creates an <see cref="System.Data.IDbCommand"/> object that can be used to
''' delete records using the <c>FK_CustomerCustomerDemo</c> foreign key.
''' </summary>
''' <param name="customerTypeID">The <c>CustomerTypeID</c> column value.</param>
''' <returns>A reference to the <see cref="System.Data.IDbCommand"/> object.</returns>
Public Overridable Function CreateDeleteByCustomerTypeIDCommand(customerTypeID As String) As IDbCommand
Dim cmd As IDbCommand = _db.CreateCommand("dbo._CustomerCustomerDemo_DeleteBy_CustomerTypeID", True)
AddParameter(cmd, "CustomerTypeID", customerTypeID)
Return cmd
End Function
''' <summary>
''' Deletes records from the <c>CustomerCustomerDemo</c> table using the
''' <c>FK_CustomerCustomerDemo_Customers</c> foreign key.
''' </summary>
''' <param name="customerID">The <c>CustomerID</c> column value.</param>
''' <returns>The number of records deleted from the table.</returns>
Public Function DeleteByCustomerID(customerID As String) As Integer
Return CreateDeleteByCustomerIDCommand(customerID).ExecuteNonQuery()
End Function
''' <summary>
''' Creates an <see cref="System.Data.IDbCommand"/> object that can be used to
''' delete records using the <c>FK_CustomerCustomerDemo_Customers</c> foreign key.
''' </summary>
''' <param name="customerID">The <c>CustomerID</c> column value.</param>
''' <returns>A reference to the <see cref="System.Data.IDbCommand"/> object.</returns>
Public Overridable Function CreateDeleteByCustomerIDCommand(customerID As String) As IDbCommand
Dim cmd As IDbCommand = _db.CreateCommand("dbo._CustomerCustomerDemo_DeleteBy_CustomerID", True)
AddParameter(cmd, "CustomerID", customerID)
Return cmd
End Function
''' <summary>
''' Deletes <c>CustomerCustomerDemo</c> records that match the specified criteria.
''' </summary>
''' <param name="whereSql">The SQL search condition.
''' For example: <c>"FirstName='Smith' AND Zip=75038"</c>.</param>
''' <returns>The number of deleted records.</returns>
Public Function Delete(whereSql As String) As Integer
Return CreateDeleteCommand(whereSql).ExecuteNonQuery()
End Function
''' <summary>
''' Creates an <see cref="System.Data.IDbCommand"/> object that can be used
''' to delete <c>CustomerCustomerDemo</c> records that match the specified criteria.
''' </summary>
''' <param name="whereSql">The SQL search condition.
''' For example: <c>"FirstName='Smith' AND Zip=75038"</c>.</param>
''' <returns>A reference to the <see cref="System.Data.IDbCommand"/> object.</returns>
Protected Overridable Function CreateDeleteCommand(whereSql As String) As IDbCommand
Dim sql As String = "DELETE FROM [dbo].[CustomerCustomerDemo]"
If Not(whereSql Is Nothing) AndAlso 0 < whereSql.Length Then
sql += " WHERE " + whereSql
End If
Return _db.CreateCommand(sql)
End Function
''' <summary>
''' Deletes all records from the <c>CustomerCustomerDemo</c> table.
''' </summary>
''' <returns>The number of deleted records.</returns>
Public Function DeleteAll() As Integer
Return _db.CreateCommand("dbo._CustomerCustomerDemo_DeleteAll", true).ExecuteNonQuery()
End Function
''' <summary>
''' Reads data using the specified command and returns
''' an array of mapped objects.
''' </summary>
''' <param name="command">The <see cref="System.Data.IDbCommand"/> object.</param>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Protected Function MapRecords(command As IDbCommand) As CustomerCustomerDemoRow()
Dim reader As IDataReader = _db.ExecuteReader(command)
Try
Return MapRecords(reader)
Finally
reader.Dispose()
End Try
End Function
''' <summary>
''' Reads data from the provided data reader and returns
''' an array of mapped objects.
''' </summary>
''' <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Protected Function MapRecords(reader As IDataReader) As CustomerCustomerDemoRow()
Dim totalRecordCount As Integer = -1
Return MapRecords(reader, 0, Integer.MaxValue, totalRecordCount)
End Function
''' <summary>
''' Reads data from the provided data reader and returns
''' an array of mapped objects.
''' </summary>
''' <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
''' <param name="startIndex">The index of the first record to map.</param>
''' <param name="length">The number of records to map.</param>
''' <param name="totalRecordCount">A reference parameter that returns the total number
''' of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
''' <returns>An array of <see cref="CustomerCustomerDemoRow"/> objects.</returns>
Protected Overridable Function MapRecords(reader As IDataReader, startIndex As Integer, _
length As Integer, ByRef totalRecordCount As Integer) As CustomerCustomerDemoRow()
If 0 > startIndex Then
Throw New ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.")
End If
If 0 > length Then
Throw New ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.")
End If
Dim customerIDColumnIndex As Integer = reader.GetOrdinal("CustomerID")
Dim customerTypeIDColumnIndex As Integer = reader.GetOrdinal("CustomerTypeID")
Dim recordList As System.Collections.ArrayList = New System.Collections.ArrayList()
Dim ri As Integer = -startIndex
While(reader.Read())
ri = ri + 1
If ri > 0 AND ri <= length Then
Dim record As CustomerCustomerDemoRow = New CustomerCustomerDemoRow()
recordList.Add(record)
record.CustomerID = Convert.ToString(reader.GetValue(customerIDColumnIndex))
record.CustomerTypeID = Convert.ToString(reader.GetValue(customerTypeIDColumnIndex))
If ri = length AND 0 <> totalRecordCount Then
Exit While
End If
End If
End While
If 0 = totalRecordCount
totalRecordCount = ri + startIndex
Else
totalRecordCount = -1
End If
Return CType(recordList.ToArray(GetType(CustomerCustomerDemoRow)), CustomerCustomerDemoRow())
End Function
''' <summary>
''' Reads data using the specified command and returns
''' a filled <see cref="System.Data.DataTable"/> object.
''' </summary>
''' <param name="command">The <see cref="System.Data.IDbCommand"/> object.</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Protected Function MapRecordsToDataTable(command As IDbCommand) As DataTable
Dim reader As IDataReader = _db.ExecuteReader(command)
Try
Return MapRecordsToDataTable(reader)
Finally
reader.Dispose()
End Try
End Function
''' <summary>
''' Reads data from the provided data reader and returns
''' a filled <see cref="System.Data.DataTable"/> object.
''' </summary>
''' <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Protected Function MapRecordsToDataTable(reader As IDataReader) As DataTable
Dim totalRecordCount As Integer = 0
Return MapRecordsToDataTable(reader, 0, Integer.MaxValue, totalRecordCount)
End Function
''' <summary>
''' Reads data from the provided data reader and returns
''' a filled <see cref="System.Data.DataTable"/> object.
''' </summary>
''' <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param>
''' <param name="startIndex">The index of the first record to read.</param>
''' <param name="length">The number of records to read.</param>
''' <param name="totalRecordCount">A reference parameter that returns the total number
''' of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Protected Overridable Function MapRecordsToDataTable(reader As IDataReader, startIndex As Integer, _
length As Integer, ByRef totalRecordCount As Integer) As DataTable
If 0 > startIndex Then
Throw New ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero.")
End If
If 0 > length Then
Throw New ArgumentOutOfRangeException("length", length, "Length cannot be less than zero.")
End If
Dim columnCount As Integer = reader.FieldCount
Dim ri As Integer = -startIndex
Dim dataTable As DataTable = CreateDataTable()
dataTable.BeginLoadData()
Dim values(columnCount - 1) As Object
While(reader.Read())
ri = ri + 1
If ri > 0 AND ri <= length Then
reader.GetValues(values)
dataTable.LoadDataRow(values, True)
If ri = length AND 0 <> totalRecordCount Then
Exit While
End If
End If
End While
dataTable.EndLoadData()
If 0 = totalRecordCount
totalRecordCount = ri + startIndex
Else
totalRecordCount = -1
End If
Return dataTable
End Function
''' <summary>
''' Converts <see cref="System.Data.DataRow"/> to <see cref="CustomerCustomerDemoRow"/>.
''' </summary>
''' <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
''' <returns>A reference to the <see cref="CustomerCustomerDemoRow"/> object.</returns>
Protected Overridable Function MapRow(row As DataRow) As CustomerCustomerDemoRow
Dim mappedObject As CustomerCustomerDemoRow = New CustomerCustomerDemoRow()
Dim dataTable As DataTable = row.Table
Dim dataColumn As DataColumn
' Column "CustomerID"
dataColumn = dataTable.Columns("CustomerID")
If Not row.IsNull(dataColumn) Then
mappedObject.CustomerID = CType(row(dataColumn), String)
End If
' Column "CustomerTypeID"
dataColumn = dataTable.Columns("CustomerTypeID")
If Not row.IsNull(dataColumn) Then
mappedObject.CustomerTypeID = CType(row(dataColumn), String)
End If
Return mappedObject
End Function
''' <summary>
''' Creates a <see cref="System.Data.DataTable"/> object for
''' the <c>CustomerCustomerDemo</c> table.
''' </summary>
''' <returns>A reference to the <see cref="System.Data.DataTable"/> object.</returns>
Protected Overridable Function CreateDataTable() As DataTable
Dim dataTable As DataTable = new DataTable()
dataTable.TableName = "CustomerCustomerDemo"
Dim dataColumn As DataColumn
' Create the "CustomerID" column
dataColumn = dataTable.Columns.Add("CustomerID", GetType(String))
dataColumn.MaxLength = 5
dataColumn.AllowDBNull = False
' Create the "CustomerTypeID" column
dataColumn = dataTable.Columns.Add("CustomerTypeID", GetType(String))
dataColumn.MaxLength = 10
dataColumn.AllowDBNull = False
Return dataTable
End Function
''' <summary>
''' Adds a new parameter to the specified command.
''' </summary>
''' <param name="cmd">The <see cref="System.Data.IDbCommand"/> object to add the parameter to.</param>
''' <param name="paramName">The name of the parameter.</param>
''' <param name="value">The value of the parameter.</param>
''' <returns>A reference to the added parameter.</returns>
Protected Overridable Function AddParameter(cmd As IDbCommand, paramName As String, _
value As Object) As IDbDataParameter
Dim parameter As IDbDataParameter
Select paramName
Case "CustomerID"
parameter = _db.AddParameter(cmd, paramName, DbType.StringFixedLength, value)
Case "CustomerTypeID"
parameter = _db.AddParameter(cmd, paramName, DbType.StringFixedLength, value)
Case Else
Throw New ArgumentException("Unknown parameter name (" + paramName + ").")
End Select
Return parameter
End Function
End Class