
'===============================================================================
'  Generated From - SQLite_VBNet_BusinessEntity.vbgen
'
'  NEVER EDIT THIS FILE.
'
'  Public Class YourObject
'    Inherits _YourObject
'
'  End Class
'
'===============================================================================

' Generated by MyGeneration Version # (1.1.0.0)

Imports System
Imports System.Data
Imports Finisar.SQLite
Imports System.Collections
Imports System.Collections.Specialized

Imports MyGeneration.dOOdads

Namespace SQLite
    Public MustInherit Class _Employees
        Inherits SQLiteEntity

        Public Sub New()
            Me.QuerySource = "Employees"
            Me.MappingName = "Employees"
        End Sub

        '=================================================================
        '  Public Overrides Sub AddNew()
        '=================================================================
        '
        '=================================================================
        Public Overrides Sub AddNew()
            MyBase.AddNew()
        End Sub

        Public Overrides Sub FlushData()
            Me._whereClause = Nothing
            MyBase.FlushData()
        End Sub

        Public Overrides Function GetAutoKeyColumns() As String
            Return "EmployeeID"
        End Function

        '=================================================================
        '  	Public Function LoadAll() As Boolean
        '=================================================================
        '  Loads all of the records in the database, and sets the currentRow to the first row
        '=================================================================
        Public Function LoadAll() As Boolean

            Return Me.Query.Load()

        End Function


        '=================================================================
        ' Public Overridable Function LoadByPrimaryKey()  As Boolean
        '=================================================================
        '  Loads a single row of via the primary key
        '=================================================================
        Public Overridable Function LoadByPrimaryKey(ByVal EmployeeID As Long) As Boolean

            Me.Where.EmployeeID.Value = EmployeeID

            Return Me.Query.Load()

        End Function


#Region "Parameters"
        Protected Class Parameters

            Public Shared ReadOnly Property EmployeeID() As SQLiteParameter
                Get
                    Return New SQLiteParameter("@EmployeeID", DbType.Int64)
                End Get
            End Property

            Public Shared ReadOnly Property LastName() As SQLiteParameter
                Get
                    Return New SQLiteParameter("@LastName", DbType.String)
                End Get
            End Property

            Public Shared ReadOnly Property FirstName() As SQLiteParameter
                Get
                    Return New SQLiteParameter("@FirstName", DbType.String)
                End Get
            End Property

            Public Shared ReadOnly Property MYINTEGER() As SQLiteParameter
                Get
                    Return New SQLiteParameter("@MYINTEGER", DbType.Int64)
                End Get
            End Property

            Public Shared ReadOnly Property MYINT() As SQLiteParameter
                Get
                    Return New SQLiteParameter("@MYINT", DbType.Int32)
                End Get
            End Property

        End Class
#End Region

#Region "ColumnNames"
        Public Class ColumnNames

            Public Const EmployeeID As String = "EmployeeID"
            Public Const LastName As String = "LastName"
            Public Const FirstName As String = "FirstName"
            Public Const MYINTEGER As String = "MYINTEGER"
            Public Const MYINT As String = "MYINT"

            Public Shared Function ToPropertyName(ByVal columnName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(EmployeeID) = _Employees.PropertyNames.EmployeeID
                    ht(LastName) = _Employees.PropertyNames.LastName
                    ht(FirstName) = _Employees.PropertyNames.FirstName
                    ht(MYINTEGER) = _Employees.PropertyNames.MYINTEGER
                    ht(MYINT) = _Employees.PropertyNames.MYINT

                End If

                Return CType(ht(columnName), String)

            End Function

            Private Shared ht As Hashtable = Nothing
        End Class
#End Region

#Region "PropertyNames"
        Public Class PropertyNames

            Public Const EmployeeID As String = "EmployeeID"
            Public Const LastName As String = "LastName"
            Public Const FirstName As String = "FirstName"
            Public Const MYINTEGER As String = "MYINTEGER"
            Public Const MYINT As String = "MYINT"

            Public Shared Function ToColumnName(ByVal propertyName As String) As String

                If ht Is Nothing Then

                    ht = New Hashtable

                    ht(EmployeeID) = _Employees.ColumnNames.EmployeeID
                    ht(LastName) = _Employees.ColumnNames.LastName
                    ht(FirstName) = _Employees.ColumnNames.FirstName
                    ht(MYINTEGER) = _Employees.ColumnNames.MYINTEGER
                    ht(MYINT) = _Employees.ColumnNames.MYINT

                End If

                Return CType(ht(propertyName), String)

            End Function

            Private Shared ht As Hashtable = Nothing

        End Class
#End Region

#Region "StringPropertyNames"
        Public Class StringPropertyNames

            Public Const EmployeeID As String = "s_EmployeeID"
            Public Const LastName As String = "s_LastName"
            Public Const FirstName As String = "s_FirstName"
            Public Const MYINTEGER As String = "s_MYINTEGER"
            Public Const MYINT As String = "s_MYINT"

        End Class
#End Region

#Region "Properties"
        Public Overridable Property EmployeeID() As Long
            Get
                Return MyBase.GetLong(ColumnNames.EmployeeID)
            End Get
            Set(ByVal Value As Long)
                MyBase.SetLong(ColumnNames.EmployeeID, Value)
            End Set
        End Property

        Public Overridable Property LastName() As String
            Get
                Return MyBase.GetString(ColumnNames.LastName)
            End Get
            Set(ByVal Value As String)
                MyBase.SetString(ColumnNames.LastName, Value)
            End Set
        End Property

        Public Overridable Property FirstName() As String
            Get
                Return MyBase.GetString(ColumnNames.FirstName)
            End Get
            Set(ByVal Value As String)
                MyBase.SetString(ColumnNames.FirstName, Value)
            End Set
        End Property

        Public Overridable Property MYINTEGER() As Long
            Get
                Return MyBase.GetLong(ColumnNames.MYINTEGER)
            End Get
            Set(ByVal Value As Long)
                MyBase.SetLong(ColumnNames.MYINTEGER, Value)
            End Set
        End Property

        Public Overridable Property MYINT() As Long
            Get
                Return MyBase.GetLong(ColumnNames.MYINT)
            End Get
            Set(ByVal Value As Long)
                MyBase.SetLong(ColumnNames.MYINT, Value)
            End Set
        End Property


#End Region

#Region "String Properties"

        Public Overridable Property s_EmployeeID() As String
            Get
                If Me.IsColumnNull(ColumnNames.EmployeeID) Then
                    Return String.Empty
                Else
                    Return MyBase.GetLongAsString(ColumnNames.EmployeeID)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.EmployeeID)
                Else
                    Me.EmployeeID = MyBase.SetLongAsString(ColumnNames.EmployeeID, Value)
                End If
            End Set
        End Property

        Public Overridable Property s_LastName() As String
            Get
                If Me.IsColumnNull(ColumnNames.LastName) Then
                    Return String.Empty
                Else
                    Return MyBase.GetStringAsString(ColumnNames.LastName)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.LastName)
                Else
                    Me.LastName = MyBase.SetStringAsString(ColumnNames.LastName, Value)
                End If
            End Set
        End Property

        Public Overridable Property s_FirstName() As String
            Get
                If Me.IsColumnNull(ColumnNames.FirstName) Then
                    Return String.Empty
                Else
                    Return MyBase.GetStringAsString(ColumnNames.FirstName)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.FirstName)
                Else
                    Me.FirstName = MyBase.SetStringAsString(ColumnNames.FirstName, Value)
                End If
            End Set
        End Property

        Public Overridable Property s_MYINTEGER() As String
            Get
                If Me.IsColumnNull(ColumnNames.MYINTEGER) Then
                    Return String.Empty
                Else
                    Return MyBase.GetLongAsString(ColumnNames.MYINTEGER)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.MYINTEGER)
                Else
                    Me.MYINTEGER = MyBase.SetLongAsString(ColumnNames.MYINTEGER, Value)
                End If
            End Set
        End Property

        Public Overridable Property s_MYINT() As String
            Get
                If Me.IsColumnNull(ColumnNames.MYINT) Then
                    Return String.Empty
                Else
                    Return MyBase.GetLongAsString(ColumnNames.MYINT)
                End If
            End Get
            Set(ByVal Value As String)
                If String.Empty = Value Then
                    Me.SetColumnNull(ColumnNames.MYINT)
                Else
                    Me.MYINT = MyBase.SetLongAsString(ColumnNames.MYINT, Value)
                End If
            End Set
        End Property


#End Region

#Region "Where Clause"
        Public Class WhereClause

            Public Sub New(ByVal entity As BusinessEntity)
                Me._entity = entity
            End Sub

            Public ReadOnly Property TearOff() As TearOffWhereParameter
                Get
                    If _tearOff Is Nothing Then
                        _tearOff = New TearOffWhereParameter(Me)
                    End If

                    Return _tearOff
                End Get
            End Property

#Region "TearOff's"
            Public Class TearOffWhereParameter

                Public Sub New(ByVal clause As WhereClause)
                    Me._clause = clause
                End Sub


                Public ReadOnly Property EmployeeID() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.EmployeeID, Parameters.EmployeeID)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property LastName() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.LastName, Parameters.LastName)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property FirstName() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.FirstName, Parameters.FirstName)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property MYINTEGER() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.MYINTEGER, Parameters.MYINTEGER)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property

                Public ReadOnly Property MYINT() As WhereParameter
                    Get
                        Dim where As WhereParameter = New WhereParameter(ColumnNames.MYINT, Parameters.MYINT)
                        Me._clause._entity.Query.AddWhereParemeter(where)
                        Return where
                    End Get
                End Property


                Private _clause As WhereClause
            End Class
#End Region

            Public ReadOnly Property EmployeeID() As WhereParameter
                Get
                    If _EmployeeID_W Is Nothing Then
                        _EmployeeID_W = TearOff.EmployeeID
                    End If
                    Return _EmployeeID_W
                End Get
            End Property

            Public ReadOnly Property LastName() As WhereParameter
                Get
                    If _LastName_W Is Nothing Then
                        _LastName_W = TearOff.LastName
                    End If
                    Return _LastName_W
                End Get
            End Property

            Public ReadOnly Property FirstName() As WhereParameter
                Get
                    If _FirstName_W Is Nothing Then
                        _FirstName_W = TearOff.FirstName
                    End If
                    Return _FirstName_W
                End Get
            End Property

            Public ReadOnly Property MYINTEGER() As WhereParameter
                Get
                    If _MYINTEGER_W Is Nothing Then
                        _MYINTEGER_W = TearOff.MYINTEGER
                    End If
                    Return _MYINTEGER_W
                End Get
            End Property

            Public ReadOnly Property MYINT() As WhereParameter
                Get
                    If _MYINT_W Is Nothing Then
                        _MYINT_W = TearOff.MYINT
                    End If
                    Return _MYINT_W
                End Get
            End Property

            Private _EmployeeID_W As WhereParameter = Nothing
            Private _LastName_W As WhereParameter = Nothing
            Private _FirstName_W As WhereParameter = Nothing
            Private _MYINTEGER_W As WhereParameter = Nothing
            Private _MYINT_W As WhereParameter = Nothing

            Public Sub WhereClauseReset()

                _EmployeeID_W = Nothing
                _LastName_W = Nothing
                _FirstName_W = Nothing
                _MYINTEGER_W = Nothing
                _MYINT_W = Nothing
                Me._entity.Query.FlushWhereParameters()

            End Sub

            Private _entity As BusinessEntity
            Private _tearOff As TearOffWhereParameter
        End Class

        Public ReadOnly Property Where() As WhereClause
            Get
                If _whereClause Is Nothing Then
                    _whereClause = New WhereClause(Me)
                End If

                Return _whereClause
            End Get
        End Property

        Private _whereClause As WhereClause = Nothing
#End Region



        Protected Overrides Function GetInsertCommand() As IDbCommand

            Dim cmd As New SQLiteCommand
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "" & _
          "INSERT INTO [Employees]" & _
          "(" & _
           "[LastName]," & _
           "[FirstName]," & _
           "[MYINTEGER]," & _
           "[MYINT]" & _
          ")" & _
          "VALUES" & _
          "(" & _
           "@LastName," & _
           "@FirstName," & _
           "@MYINTEGER," & _
           "@MYINT" & _
          ")"

            CreateParameters(cmd)
            Return cmd
        End Function

        Protected Overrides Function GetUpdateCommand() As IDbCommand

            Dim cmd As New SQLiteCommand
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "" & _
          "UPDATE [Employees] SET " & _
           "[LastName]=@LastName," & _
           "[FirstName]=@FirstName," & _
           "[MYINTEGER]=@MYINTEGER," & _
           "[MYINT]=@MYINT" & _
          " WHERE " & _
           "[EmployeeID]=@EmployeeID"

            CreateParameters(cmd)
            Return cmd
        End Function

        Protected Overrides Function GetDeleteCommand() As IDbCommand

            Dim cmd As New SQLiteCommand
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "" & _
          "DELETE FROM [Employees] " & _
          " WHERE " & _
           "[EmployeeID]=@EmployeeID"

            Dim p As SQLiteParameter
            p = cmd.Parameters.Add(Parameters.EmployeeID)
            p.SourceColumn = ColumnNames.EmployeeID
            p.SourceVersion = DataRowVersion.Current


            Return cmd
        End Function

        Private Sub CreateParameters(ByVal cmd As SQLiteCommand)

            Dim p As SQLiteParameter
            p = cmd.Parameters.Add(Parameters.EmployeeID)
            p.SourceColumn = ColumnNames.EmployeeID
            p.SourceVersion = DataRowVersion.Current

            p = cmd.Parameters.Add(Parameters.LastName)
            p.SourceColumn = ColumnNames.LastName
            p.SourceVersion = DataRowVersion.Current

            p = cmd.Parameters.Add(Parameters.FirstName)
            p.SourceColumn = ColumnNames.FirstName
            p.SourceVersion = DataRowVersion.Current

            p = cmd.Parameters.Add(Parameters.MYINTEGER)
            p.SourceColumn = ColumnNames.MYINTEGER
            p.SourceVersion = DataRowVersion.Current

            p = cmd.Parameters.Add(Parameters.MYINT)
            p.SourceColumn = ColumnNames.MYINT
            p.SourceVersion = DataRowVersion.Current


        End Sub



    End Class

End Namespace
