'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:4.0.30319.18046
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Compare Binary
Option Infer On
Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations
Imports System.Linq
Imports System.Runtime.Serialization
Imports System.ServiceModel
Imports System.ServiceModel.DomainServices
Imports System.ServiceModel.DomainServices.Client
Imports System.ServiceModel.DomainServices.Client.ApplicationServices
Imports System.ServiceModel.Web
Imports System.Xml.Serialization


''' <summary>
''' Context for the RIA application.
''' </summary>
''' <remarks>
''' This context extends the base to make application services and types available
''' for consumption from code and xaml.
''' </remarks>
Partial Public NotInheritable Class WebContext
    Inherits WebContextBase
    
    #Region "Extensibility Method Definitions"

    ''' <summary>
    ''' This method is invoked from the constructor once initialization is complete and
    ''' can be used for further object setup.
    ''' </summary>
    Private Partial Sub OnCreated()
    End Sub

    #End Region
    
    
    ''' <summary>
    ''' Initializes a new instance of the WebContext class.
    ''' </summary>
    Public Sub New()
        MyBase.New
        Me.OnCreated
    End Sub
    
    ''' <summary>
    ''' Gets the context that is registered as a lifetime object with the current application.
    ''' </summary>
    ''' <exception cref="InvalidOperationException"> is thrown if there is no current application,
    ''' no contexts have been added, or more than one context has been added.
    ''' </exception>
    ''' <seealso cref="System.Windows.Application.ApplicationLifetimeObjects"/>
    Public Shadows Shared ReadOnly Property Current() As WebContext
        Get
            Return CType(WebContextBase.Current,WebContext)
        End Get
    End Property
End Class

Namespace Web
    
    ''' <summary>
    ''' The 'Category' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Category
        Inherits Entity
        
        Private _categoryID As Integer
        
        Private _categoryName As String
        
        Private _description As String
        
        Private _picture() As Byte
        
        Private _products As EntityCollection(Of Product)
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnCategoryIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnCategoryIDChanged()
        End Sub
        Private Partial Sub OnCategoryNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCategoryNameChanged()
        End Sub
        Private Partial Sub OnDescriptionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnDescriptionChanged()
        End Sub
        Private Partial Sub OnPictureChanging(ByVal value() As Byte)
        End Sub
        Private Partial Sub OnPictureChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Category"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'CategoryID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property CategoryID() As Integer
            Get
                Return Me._categoryID
            End Get
            Set
                If ((Me._categoryID = value)  _
                            = false) Then
                    Me.OnCategoryIDChanging(value)
                    Me.ValidateProperty("CategoryID", value)
                    Me._categoryID = value
                    Me.RaisePropertyChanged("CategoryID")
                    Me.OnCategoryIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'CategoryName' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(15)>  _
        Public Property CategoryName() As String
            Get
                Return Me._categoryName
            End Get
            Set
                If (String.Equals(Me._categoryName, value) = false) Then
                    Me.OnCategoryNameChanging(value)
                    Me.RaiseDataMemberChanging("CategoryName")
                    Me.ValidateProperty("CategoryName", value)
                    Me._categoryName = value
                    Me.RaiseDataMemberChanged("CategoryName")
                    Me.OnCategoryNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Description' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Description() As String
            Get
                Return Me._description
            End Get
            Set
                If (String.Equals(Me._description, value) = false) Then
                    Me.OnDescriptionChanging(value)
                    Me.RaiseDataMemberChanging("Description")
                    Me.ValidateProperty("Description", value)
                    Me._description = value
                    Me.RaiseDataMemberChanged("Description")
                    Me.OnDescriptionChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Picture' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Picture() As Byte()
            Get
                Return Me._picture
            End Get
            Set
                If (Object.Equals(Me._picture, value) = false) Then
                    Me.OnPictureChanging(value)
                    Me.RaiseDataMemberChanging("Picture")
                    Me.ValidateProperty("Picture", value)
                    Me._picture = value
                    Me.RaiseDataMemberChanged("Picture")
                    Me.OnPictureChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Product"/> entity instances.
        ''' </summary>
        <Association("Category_Product", "CategoryID", "CategoryID"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Products() As EntityCollection(Of Product)
            Get
                If (Me._products Is Nothing) Then
                    Me._products = New EntityCollection(Of Product)(Me, "Products", AddressOf Me.FilterProducts, AddressOf Me.AttachProducts, AddressOf Me.DetachProducts)
                End If
                Return Me._products
            End Get
        End Property
        
        Private Sub AttachProducts(ByVal entity As Product)
            entity.Category = Me
        End Sub
        
        Private Sub DetachProducts(ByVal entity As Product)
            entity.Category = Nothing
        End Sub
        
        Private Function FilterProducts(ByVal entity As Product) As Boolean
            Return Object.Equals(entity.CategoryID, Me.CategoryID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._categoryID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Customer' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Customer
        Inherits Entity
        
        Private _address As String
        
        Private _city As String
        
        Private _companyName As String
        
        Private _contactName As String
        
        Private _contactTitle As String
        
        Private _country As String
        
        Private _customerID As String
        
        Private _fax As String
        
        Private _orders As EntityCollection(Of Order)
        
        Private _phone As String
        
        Private _postalCode As String
        
        Private _region As String
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnAddressChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnAddressChanged()
        End Sub
        Private Partial Sub OnCityChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCityChanged()
        End Sub
        Private Partial Sub OnCompanyNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCompanyNameChanged()
        End Sub
        Private Partial Sub OnContactNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnContactNameChanged()
        End Sub
        Private Partial Sub OnContactTitleChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnContactTitleChanged()
        End Sub
        Private Partial Sub OnCountryChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCountryChanged()
        End Sub
        Private Partial Sub OnCustomerIDChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCustomerIDChanged()
        End Sub
        Private Partial Sub OnFaxChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnFaxChanged()
        End Sub
        Private Partial Sub OnPhoneChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnPhoneChanged()
        End Sub
        Private Partial Sub OnPostalCodeChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnPostalCodeChanged()
        End Sub
        Private Partial Sub OnRegionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnRegionChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Customer"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'Address' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(60)>  _
        Public Property Address() As String
            Get
                Return Me._address
            End Get
            Set
                If (String.Equals(Me._address, value) = false) Then
                    Me.OnAddressChanging(value)
                    Me.RaiseDataMemberChanging("Address")
                    Me.ValidateProperty("Address", value)
                    Me._address = value
                    Me.RaiseDataMemberChanged("Address")
                    Me.OnAddressChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'City' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property City() As String
            Get
                Return Me._city
            End Get
            Set
                If (String.Equals(Me._city, value) = false) Then
                    Me.OnCityChanging(value)
                    Me.RaiseDataMemberChanging("City")
                    Me.ValidateProperty("City", value)
                    Me._city = value
                    Me.RaiseDataMemberChanged("City")
                    Me.OnCityChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'CompanyName' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(40)>  _
        Public Property CompanyName() As String
            Get
                Return Me._companyName
            End Get
            Set
                If (String.Equals(Me._companyName, value) = false) Then
                    Me.OnCompanyNameChanging(value)
                    Me.RaiseDataMemberChanging("CompanyName")
                    Me.ValidateProperty("CompanyName", value)
                    Me._companyName = value
                    Me.RaiseDataMemberChanged("CompanyName")
                    Me.OnCompanyNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ContactName' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(30)>  _
        Public Property ContactName() As String
            Get
                Return Me._contactName
            End Get
            Set
                If (String.Equals(Me._contactName, value) = false) Then
                    Me.OnContactNameChanging(value)
                    Me.RaiseDataMemberChanging("ContactName")
                    Me.ValidateProperty("ContactName", value)
                    Me._contactName = value
                    Me.RaiseDataMemberChanged("ContactName")
                    Me.OnContactNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ContactTitle' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(30)>  _
        Public Property ContactTitle() As String
            Get
                Return Me._contactTitle
            End Get
            Set
                If (String.Equals(Me._contactTitle, value) = false) Then
                    Me.OnContactTitleChanging(value)
                    Me.RaiseDataMemberChanging("ContactTitle")
                    Me.ValidateProperty("ContactTitle", value)
                    Me._contactTitle = value
                    Me.RaiseDataMemberChanged("ContactTitle")
                    Me.OnContactTitleChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Country' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property Country() As String
            Get
                Return Me._country
            End Get
            Set
                If (String.Equals(Me._country, value) = false) Then
                    Me.OnCountryChanging(value)
                    Me.RaiseDataMemberChanging("Country")
                    Me.ValidateProperty("Country", value)
                    Me._country = value
                    Me.RaiseDataMemberChanged("Country")
                    Me.OnCountryChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'CustomerID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         Required(),  _
         RoundtripOriginal(),  _
         StringLength(5)>  _
        Public Property CustomerID() As String
            Get
                Return Me._customerID
            End Get
            Set
                If (String.Equals(Me._customerID, value) = false) Then
                    Me.OnCustomerIDChanging(value)
                    Me.ValidateProperty("CustomerID", value)
                    Me._customerID = value
                    Me.RaisePropertyChanged("CustomerID")
                    Me.OnCustomerIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Fax' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(24)>  _
        Public Property Fax() As String
            Get
                Return Me._fax
            End Get
            Set
                If (String.Equals(Me._fax, value) = false) Then
                    Me.OnFaxChanging(value)
                    Me.RaiseDataMemberChanging("Fax")
                    Me.ValidateProperty("Fax", value)
                    Me._fax = value
                    Me.RaiseDataMemberChanged("Fax")
                    Me.OnFaxChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Order"/> entity instances.
        ''' </summary>
        <Association("Customer_Order", "CustomerID", "CustomerID"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Orders() As EntityCollection(Of Order)
            Get
                If (Me._orders Is Nothing) Then
                    Me._orders = New EntityCollection(Of Order)(Me, "Orders", AddressOf Me.FilterOrders, AddressOf Me.AttachOrders, AddressOf Me.DetachOrders)
                End If
                Return Me._orders
            End Get
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Phone' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(24)>  _
        Public Property Phone() As String
            Get
                Return Me._phone
            End Get
            Set
                If (String.Equals(Me._phone, value) = false) Then
                    Me.OnPhoneChanging(value)
                    Me.RaiseDataMemberChanging("Phone")
                    Me.ValidateProperty("Phone", value)
                    Me._phone = value
                    Me.RaiseDataMemberChanged("Phone")
                    Me.OnPhoneChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'PostalCode' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(10)>  _
        Public Property PostalCode() As String
            Get
                Return Me._postalCode
            End Get
            Set
                If (String.Equals(Me._postalCode, value) = false) Then
                    Me.OnPostalCodeChanging(value)
                    Me.RaiseDataMemberChanging("PostalCode")
                    Me.ValidateProperty("PostalCode", value)
                    Me._postalCode = value
                    Me.RaiseDataMemberChanged("PostalCode")
                    Me.OnPostalCodeChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Region' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property Region() As String
            Get
                Return Me._region
            End Get
            Set
                If (String.Equals(Me._region, value) = false) Then
                    Me.OnRegionChanging(value)
                    Me.RaiseDataMemberChanging("Region")
                    Me.ValidateProperty("Region", value)
                    Me._region = value
                    Me.RaiseDataMemberChanged("Region")
                    Me.OnRegionChanged
                End If
            End Set
        End Property
        
        Private Sub AttachOrders(ByVal entity As Order)
            entity.Customer = Me
        End Sub
        
        Private Sub DetachOrders(ByVal entity As Order)
            entity.Customer = Nothing
        End Sub
        
        Private Function FilterOrders(ByVal entity As Order) As Boolean
            Return Object.Equals(entity.CustomerID, Me.CustomerID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._customerID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'CustomerDemographic' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class CustomerDemographic
        Inherits Entity
        
        Private _customerDesc As String
        
        Private _customerTypeID As String
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnCustomerDescChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCustomerDescChanged()
        End Sub
        Private Partial Sub OnCustomerTypeIDChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCustomerTypeIDChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="CustomerDemographic"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'CustomerDesc' value.
        ''' </summary>
        <DataMember()>  _
        Public Property CustomerDesc() As String
            Get
                Return Me._customerDesc
            End Get
            Set
                If (String.Equals(Me._customerDesc, value) = false) Then
                    Me.OnCustomerDescChanging(value)
                    Me.RaiseDataMemberChanging("CustomerDesc")
                    Me.ValidateProperty("CustomerDesc", value)
                    Me._customerDesc = value
                    Me.RaiseDataMemberChanged("CustomerDesc")
                    Me.OnCustomerDescChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'CustomerTypeID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         Required(),  _
         RoundtripOriginal(),  _
         StringLength(10)>  _
        Public Property CustomerTypeID() As String
            Get
                Return Me._customerTypeID
            End Get
            Set
                If (String.Equals(Me._customerTypeID, value) = false) Then
                    Me.OnCustomerTypeIDChanging(value)
                    Me.ValidateProperty("CustomerTypeID", value)
                    Me._customerTypeID = value
                    Me.RaisePropertyChanged("CustomerTypeID")
                    Me.OnCustomerTypeIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._customerTypeID
        End Function
    End Class
    
    ''' <summary>
    ''' The DomainContext corresponding to the 'DomainService1' DomainService.
    ''' </summary>
    Partial Public NotInheritable Class DomainService1
        Inherits DomainContext
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="DomainService1"/> class.
        ''' </summary>
        Public Sub New()
            Me.New(New WebDomainClient(Of IDomainService1Contract)(New Uri("TutorialsSilverlight-Web-DomainService1.svc", UriKind.Relative)))
        End Sub
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="DomainService1"/> class with the specified service URI.
        ''' </summary>
        ''' <param name="serviceUri">The DomainService1 service URI.</param>
        Public Sub New(ByVal serviceUri As Uri)
            Me.New(New WebDomainClient(Of IDomainService1Contract)(serviceUri))
        End Sub
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="DomainService1"/> class with the specified <paramref name="domainClient"/>.
        ''' </summary>
        ''' <param name="domainClient">The DomainClient instance to use for this DomainContext.</param>
        Public Sub New(ByVal domainClient As DomainClient)
            MyBase.New(domainClient)
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets the set of <see cref="Category"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Categories() As EntitySet(Of Category)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Category)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="CustomerDemographic"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property CustomerDemographics() As EntitySet(Of CustomerDemographic)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of CustomerDemographic)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Customer"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Customers() As EntitySet(Of Customer)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Customer)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Employee"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Employees() As EntitySet(Of Employee)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Employee)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Order_Detail"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Order_Details() As EntitySet(Of Order_Detail)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Order_Detail)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Order"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Orders() As EntitySet(Of Order)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Order)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Product"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Products() As EntitySet(Of Product)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Product)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Region"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Regions() As EntitySet(Of Region)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Region)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Shipper"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Shippers() As EntitySet(Of Shipper)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Shipper)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Supplier"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Suppliers() As EntitySet(Of Supplier)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Supplier)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets the set of <see cref="Territory"/> entity instances that have been loaded into this <see cref="DomainService1"/> instance.
        ''' </summary>
        Public ReadOnly Property Territories() As EntitySet(Of Territory)
            Get
                Return MyBase.EntityContainer.GetEntitySet(Of Territory)
            End Get
        End Property
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Category"/> entity instances using the 'GetCategories' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Category"/> entity instances.</returns>
        Public Function GetCategoriesQuery() As EntityQuery(Of Category)
            Me.ValidateMethod("GetCategoriesQuery", Nothing)
            Return MyBase.CreateQuery(Of Category)("GetCategories", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="CustomerDemographic"/> entity instances using the 'GetCustomerDemographics' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="CustomerDemographic"/> entity instances.</returns>
        Public Function GetCustomerDemographicsQuery() As EntityQuery(Of CustomerDemographic)
            Me.ValidateMethod("GetCustomerDemographicsQuery", Nothing)
            Return MyBase.CreateQuery(Of CustomerDemographic)("GetCustomerDemographics", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Customer"/> entity instances using the 'GetCustomers' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Customer"/> entity instances.</returns>
        Public Function GetCustomersQuery() As EntityQuery(Of Customer)
            Me.ValidateMethod("GetCustomersQuery", Nothing)
            Return MyBase.CreateQuery(Of Customer)("GetCustomers", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Employee"/> entity instances using the 'GetEmployees' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Employee"/> entity instances.</returns>
        Public Function GetEmployeesQuery() As EntityQuery(Of Employee)
            Me.ValidateMethod("GetEmployeesQuery", Nothing)
            Return MyBase.CreateQuery(Of Employee)("GetEmployees", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Order_Detail"/> entity instances using the 'GetOrder_Details' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Order_Detail"/> entity instances.</returns>
        Public Function GetOrder_DetailsQuery() As EntityQuery(Of Order_Detail)
            Me.ValidateMethod("GetOrder_DetailsQuery", Nothing)
            Return MyBase.CreateQuery(Of Order_Detail)("GetOrder_Details", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Order"/> entity instances using the 'GetOrders' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Order"/> entity instances.</returns>
        Public Function GetOrdersQuery() As EntityQuery(Of Order)
            Me.ValidateMethod("GetOrdersQuery", Nothing)
            Return MyBase.CreateQuery(Of Order)("GetOrders", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Product"/> entity instances using the 'GetProducts' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Product"/> entity instances.</returns>
        Public Function GetProductsQuery() As EntityQuery(Of Product)
            Me.ValidateMethod("GetProductsQuery", Nothing)
            Return MyBase.CreateQuery(Of Product)("GetProducts", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Region"/> entity instances using the 'GetRegions' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Region"/> entity instances.</returns>
        Public Function GetRegionsQuery() As EntityQuery(Of Region)
            Me.ValidateMethod("GetRegionsQuery", Nothing)
            Return MyBase.CreateQuery(Of Region)("GetRegions", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Shipper"/> entity instances using the 'GetShippers' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Shipper"/> entity instances.</returns>
        Public Function GetShippersQuery() As EntityQuery(Of Shipper)
            Me.ValidateMethod("GetShippersQuery", Nothing)
            Return MyBase.CreateQuery(Of Shipper)("GetShippers", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Supplier"/> entity instances using the 'GetSuppliers' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Supplier"/> entity instances.</returns>
        Public Function GetSuppliersQuery() As EntityQuery(Of Supplier)
            Me.ValidateMethod("GetSuppliersQuery", Nothing)
            Return MyBase.CreateQuery(Of Supplier)("GetSuppliers", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Gets an EntityQuery instance that can be used to load <see cref="Territory"/> entity instances using the 'GetTerritories' query.
        ''' </summary>
        ''' <returns>An EntityQuery that can be loaded to retrieve <see cref="Territory"/> entity instances.</returns>
        Public Function GetTerritoriesQuery() As EntityQuery(Of Territory)
            Me.ValidateMethod("GetTerritoriesQuery", Nothing)
            Return MyBase.CreateQuery(Of Territory)("GetTerritories", Nothing, false, true)
        End Function
        
        ''' <summary>
        ''' Creates a new EntityContainer for this DomainContext's EntitySets.
        ''' </summary>
        ''' <returns>A new container instance.</returns>
        Protected Overrides Function CreateEntityContainer() As EntityContainer
            Return New DomainService1EntityContainer()
        End Function
        
        ''' <summary>
        ''' Service contract for the 'DomainService1' DomainService.
        ''' </summary>
        <ServiceContract()>  _
        Public Interface IDomainService1Contract
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetCategories' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetCategoriesDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetCategories", ReplyAction:="http://tempuri.org/DomainService1/GetCategoriesResponse"),  _
             WebGet()>  _
            Function BeginGetCategories(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetCategories'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetCategories'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetCategories' operation.</returns>
            Function EndGetCategories(ByVal result As IAsyncResult) As QueryResult(Of Category)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetCustomerDemographics' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetCustomerDemographicsDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetCustomerDemographics", ReplyAction:="http://tempuri.org/DomainService1/GetCustomerDemographicsResponse"),  _
             WebGet()>  _
            Function BeginGetCustomerDemographics(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetCustomerDemographics'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetCustomerDemographics'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetCustomerDemographics' operation.</returns>
            Function EndGetCustomerDemographics(ByVal result As IAsyncResult) As QueryResult(Of CustomerDemographic)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetCustomers' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetCustomersDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetCustomers", ReplyAction:="http://tempuri.org/DomainService1/GetCustomersResponse"),  _
             WebGet()>  _
            Function BeginGetCustomers(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetCustomers'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetCustomers'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetCustomers' operation.</returns>
            Function EndGetCustomers(ByVal result As IAsyncResult) As QueryResult(Of Customer)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetEmployees' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetEmployeesDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetEmployees", ReplyAction:="http://tempuri.org/DomainService1/GetEmployeesResponse"),  _
             WebGet()>  _
            Function BeginGetEmployees(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetEmployees'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetEmployees'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetEmployees' operation.</returns>
            Function EndGetEmployees(ByVal result As IAsyncResult) As QueryResult(Of Employee)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetOrder_Details' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetOrder_DetailsDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetOrder_Details", ReplyAction:="http://tempuri.org/DomainService1/GetOrder_DetailsResponse"),  _
             WebGet()>  _
            Function BeginGetOrder_Details(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetOrder_Details'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetOrder_Details'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetOrder_Details' operation.</returns>
            Function EndGetOrder_Details(ByVal result As IAsyncResult) As QueryResult(Of Order_Detail)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetOrders' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetOrdersDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetOrders", ReplyAction:="http://tempuri.org/DomainService1/GetOrdersResponse"),  _
             WebGet()>  _
            Function BeginGetOrders(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetOrders'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetOrders'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetOrders' operation.</returns>
            Function EndGetOrders(ByVal result As IAsyncResult) As QueryResult(Of Order)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetProducts' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetProductsDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetProducts", ReplyAction:="http://tempuri.org/DomainService1/GetProductsResponse"),  _
             WebGet()>  _
            Function BeginGetProducts(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetProducts'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetProducts'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetProducts' operation.</returns>
            Function EndGetProducts(ByVal result As IAsyncResult) As QueryResult(Of Product)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetRegions' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetRegionsDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetRegions", ReplyAction:="http://tempuri.org/DomainService1/GetRegionsResponse"),  _
             WebGet()>  _
            Function BeginGetRegions(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetRegions'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetRegions'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetRegions' operation.</returns>
            Function EndGetRegions(ByVal result As IAsyncResult) As QueryResult(Of Region)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetShippers' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetShippersDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetShippers", ReplyAction:="http://tempuri.org/DomainService1/GetShippersResponse"),  _
             WebGet()>  _
            Function BeginGetShippers(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetShippers'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetShippers'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetShippers' operation.</returns>
            Function EndGetShippers(ByVal result As IAsyncResult) As QueryResult(Of Shipper)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetSuppliers' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetSuppliersDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetSuppliers", ReplyAction:="http://tempuri.org/DomainService1/GetSuppliersResponse"),  _
             WebGet()>  _
            Function BeginGetSuppliers(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetSuppliers'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetSuppliers'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetSuppliers' operation.</returns>
            Function EndGetSuppliers(ByVal result As IAsyncResult) As QueryResult(Of Supplier)
            
            ''' <summary>
            ''' Asynchronously invokes the 'GetTerritories' operation.
            ''' </summary>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/GetTerritoriesDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/GetTerritories", ReplyAction:="http://tempuri.org/DomainService1/GetTerritoriesResponse"),  _
             WebGet()>  _
            Function BeginGetTerritories(ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginGetTerritories'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginGetTerritories'.</param>
            ''' <returns>The 'QueryResult' returned from the 'GetTerritories' operation.</returns>
            Function EndGetTerritories(ByVal result As IAsyncResult) As QueryResult(Of Territory)
            
            ''' <summary>
            ''' Asynchronously invokes the 'SubmitChanges' operation.
            ''' </summary>
            ''' <param name="changeSet">The change-set to submit.</param>
            ''' <param name="callback">Callback to invoke on completion.</param>
            ''' <param name="asyncState">Optional state object.</param>
            ''' <returns>An IAsyncResult that can be used to monitor the request.</returns>
            <FaultContract(GetType(DomainServiceFault), Action:="http://tempuri.org/DomainService1/SubmitChangesDomainServiceFault", Name:="DomainServiceFault", [Namespace]:="DomainServices"),  _
             OperationContract(AsyncPattern:=true, Action:="http://tempuri.org/DomainService1/SubmitChanges", ReplyAction:="http://tempuri.org/DomainService1/SubmitChangesResponse")>  _
            Function BeginSubmitChanges(ByVal changeSet As IEnumerable(Of ChangeSetEntry), ByVal callback As AsyncCallback, ByVal asyncState As Object) As IAsyncResult
            
            ''' <summary>
            ''' Completes the asynchronous operation begun by 'BeginSubmitChanges'.
            ''' </summary>
            ''' <param name="result">The IAsyncResult returned from 'BeginSubmitChanges'.</param>
            ''' <returns>The collection of change-set entry elements returned from 'SubmitChanges'.</returns>
            Function EndSubmitChanges(ByVal result As IAsyncResult) As IEnumerable(Of ChangeSetEntry)
        End Interface
        
        Friend NotInheritable Class DomainService1EntityContainer
            Inherits EntityContainer
            
            Public Sub New()
                MyBase.New
                Me.CreateEntitySet(Of Category)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Customer)(EntitySetOperations.All)
                Me.CreateEntitySet(Of CustomerDemographic)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Employee)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Order)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Order_Detail)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Product)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Region)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Shipper)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Supplier)(EntitySetOperations.All)
                Me.CreateEntitySet(Of Territory)(EntitySetOperations.All)
            End Sub
        End Class
    End Class
    
    ''' <summary>
    ''' The 'Employee' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Employee
        Inherits Entity
        
        Private _address As String
        
        Private _birthDate As Nullable(Of DateTime)
        
        Private _city As String
        
        Private _country As String
        
        Private _employee1 As EntityRef(Of Employee)
        
        Private _employeeID As Integer
        
        Private _employees1 As EntityCollection(Of Employee)
        
        Private _extension As String
        
        Private _firstName As String
        
        Private _hireDate As Nullable(Of DateTime)
        
        Private _homePhone As String
        
        Private _lastName As String
        
        Private _notes As String
        
        Private _orders As EntityCollection(Of Order)
        
        Private _photo() As Byte
        
        Private _photoPath As String
        
        Private _postalCode As String
        
        Private _region As String
        
        Private _reportsTo As Nullable(Of Integer)
        
        Private _title As String
        
        Private _titleOfCourtesy As String
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnAddressChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnAddressChanged()
        End Sub
        Private Partial Sub OnBirthDateChanging(ByVal value As Nullable(Of DateTime))
        End Sub
        Private Partial Sub OnBirthDateChanged()
        End Sub
        Private Partial Sub OnCityChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCityChanged()
        End Sub
        Private Partial Sub OnCountryChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCountryChanged()
        End Sub
        Private Partial Sub OnEmployeeIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnEmployeeIDChanged()
        End Sub
        Private Partial Sub OnExtensionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnExtensionChanged()
        End Sub
        Private Partial Sub OnFirstNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnFirstNameChanged()
        End Sub
        Private Partial Sub OnHireDateChanging(ByVal value As Nullable(Of DateTime))
        End Sub
        Private Partial Sub OnHireDateChanged()
        End Sub
        Private Partial Sub OnHomePhoneChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnHomePhoneChanged()
        End Sub
        Private Partial Sub OnLastNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnLastNameChanged()
        End Sub
        Private Partial Sub OnNotesChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnNotesChanged()
        End Sub
        Private Partial Sub OnPhotoChanging(ByVal value() As Byte)
        End Sub
        Private Partial Sub OnPhotoChanged()
        End Sub
        Private Partial Sub OnPhotoPathChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnPhotoPathChanged()
        End Sub
        Private Partial Sub OnPostalCodeChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnPostalCodeChanged()
        End Sub
        Private Partial Sub OnRegionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnRegionChanged()
        End Sub
        Private Partial Sub OnReportsToChanging(ByVal value As Nullable(Of Integer))
        End Sub
        Private Partial Sub OnReportsToChanged()
        End Sub
        Private Partial Sub OnTitleChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnTitleChanged()
        End Sub
        Private Partial Sub OnTitleOfCourtesyChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnTitleOfCourtesyChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Employee"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'Address' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(60)>  _
        Public Property Address() As String
            Get
                Return Me._address
            End Get
            Set
                If (String.Equals(Me._address, value) = false) Then
                    Me.OnAddressChanging(value)
                    Me.RaiseDataMemberChanging("Address")
                    Me.ValidateProperty("Address", value)
                    Me._address = value
                    Me.RaiseDataMemberChanged("Address")
                    Me.OnAddressChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'BirthDate' value.
        ''' </summary>
        <DataMember()>  _
        Public Property BirthDate() As Nullable(Of DateTime)
            Get
                Return Me._birthDate
            End Get
            Set
                If (Me._birthDate.Equals(value) = false) Then
                    Me.OnBirthDateChanging(value)
                    Me.RaiseDataMemberChanging("BirthDate")
                    Me.ValidateProperty("BirthDate", value)
                    Me._birthDate = value
                    Me.RaiseDataMemberChanged("BirthDate")
                    Me.OnBirthDateChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'City' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property City() As String
            Get
                Return Me._city
            End Get
            Set
                If (String.Equals(Me._city, value) = false) Then
                    Me.OnCityChanging(value)
                    Me.RaiseDataMemberChanging("City")
                    Me.ValidateProperty("City", value)
                    Me._city = value
                    Me.RaiseDataMemberChanged("City")
                    Me.OnCityChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Country' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property Country() As String
            Get
                Return Me._country
            End Get
            Set
                If (String.Equals(Me._country, value) = false) Then
                    Me.OnCountryChanging(value)
                    Me.RaiseDataMemberChanging("Country")
                    Me.ValidateProperty("Country", value)
                    Me._country = value
                    Me.RaiseDataMemberChanged("Country")
                    Me.OnCountryChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Employee"/> entity.
        ''' </summary>
        <Association("Employee_Employee", "ReportsTo", "EmployeeID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Employee1() As Employee
            Get
                If (Me._employee1 Is Nothing) Then
                    Me._employee1 = New EntityRef(Of Employee)(Me, "Employee1", AddressOf Me.FilterEmployee1)
                End If
                Return Me._employee1.Entity
            End Get
            Set
                Dim previous As Employee = Me.Employee1
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Employee1", value)
                    If (Not (previous) Is Nothing) Then
                        Me._employee1.Entity = Nothing
                        previous.Employees1.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.ReportsTo = value.EmployeeID
                    Else
                        Me.ReportsTo = CType(Nothing, Nullable(Of Integer))
                    End If
                    Me._employee1.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Employees1.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Employee1")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'EmployeeID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property EmployeeID() As Integer
            Get
                Return Me._employeeID
            End Get
            Set
                If ((Me._employeeID = value)  _
                            = false) Then
                    Me.OnEmployeeIDChanging(value)
                    Me.ValidateProperty("EmployeeID", value)
                    Me._employeeID = value
                    Me.RaisePropertyChanged("EmployeeID")
                    Me.OnEmployeeIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Employee"/> entity instances.
        ''' </summary>
        <Association("Employee_Employee", "EmployeeID", "ReportsTo"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Employees1() As EntityCollection(Of Employee)
            Get
                If (Me._employees1 Is Nothing) Then
                    Me._employees1 = New EntityCollection(Of Employee)(Me, "Employees1", AddressOf Me.FilterEmployees1, AddressOf Me.AttachEmployees1, AddressOf Me.DetachEmployees1)
                End If
                Return Me._employees1
            End Get
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Extension' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(4)>  _
        Public Property Extension() As String
            Get
                Return Me._extension
            End Get
            Set
                If (String.Equals(Me._extension, value) = false) Then
                    Me.OnExtensionChanging(value)
                    Me.RaiseDataMemberChanging("Extension")
                    Me.ValidateProperty("Extension", value)
                    Me._extension = value
                    Me.RaiseDataMemberChanged("Extension")
                    Me.OnExtensionChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'FirstName' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(10)>  _
        Public Property FirstName() As String
            Get
                Return Me._firstName
            End Get
            Set
                If (String.Equals(Me._firstName, value) = false) Then
                    Me.OnFirstNameChanging(value)
                    Me.RaiseDataMemberChanging("FirstName")
                    Me.ValidateProperty("FirstName", value)
                    Me._firstName = value
                    Me.RaiseDataMemberChanged("FirstName")
                    Me.OnFirstNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'HireDate' value.
        ''' </summary>
        <DataMember()>  _
        Public Property HireDate() As Nullable(Of DateTime)
            Get
                Return Me._hireDate
            End Get
            Set
                If (Me._hireDate.Equals(value) = false) Then
                    Me.OnHireDateChanging(value)
                    Me.RaiseDataMemberChanging("HireDate")
                    Me.ValidateProperty("HireDate", value)
                    Me._hireDate = value
                    Me.RaiseDataMemberChanged("HireDate")
                    Me.OnHireDateChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'HomePhone' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(24)>  _
        Public Property HomePhone() As String
            Get
                Return Me._homePhone
            End Get
            Set
                If (String.Equals(Me._homePhone, value) = false) Then
                    Me.OnHomePhoneChanging(value)
                    Me.RaiseDataMemberChanging("HomePhone")
                    Me.ValidateProperty("HomePhone", value)
                    Me._homePhone = value
                    Me.RaiseDataMemberChanged("HomePhone")
                    Me.OnHomePhoneChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'LastName' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(20)>  _
        Public Property LastName() As String
            Get
                Return Me._lastName
            End Get
            Set
                If (String.Equals(Me._lastName, value) = false) Then
                    Me.OnLastNameChanging(value)
                    Me.RaiseDataMemberChanging("LastName")
                    Me.ValidateProperty("LastName", value)
                    Me._lastName = value
                    Me.RaiseDataMemberChanged("LastName")
                    Me.OnLastNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Notes' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Notes() As String
            Get
                Return Me._notes
            End Get
            Set
                If (String.Equals(Me._notes, value) = false) Then
                    Me.OnNotesChanging(value)
                    Me.RaiseDataMemberChanging("Notes")
                    Me.ValidateProperty("Notes", value)
                    Me._notes = value
                    Me.RaiseDataMemberChanged("Notes")
                    Me.OnNotesChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Order"/> entity instances.
        ''' </summary>
        <Association("Employee_Order", "EmployeeID", "EmployeeID"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Orders() As EntityCollection(Of Order)
            Get
                If (Me._orders Is Nothing) Then
                    Me._orders = New EntityCollection(Of Order)(Me, "Orders", AddressOf Me.FilterOrders, AddressOf Me.AttachOrders, AddressOf Me.DetachOrders)
                End If
                Return Me._orders
            End Get
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Photo' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Photo() As Byte()
            Get
                Return Me._photo
            End Get
            Set
                If (Object.Equals(Me._photo, value) = false) Then
                    Me.OnPhotoChanging(value)
                    Me.RaiseDataMemberChanging("Photo")
                    Me.ValidateProperty("Photo", value)
                    Me._photo = value
                    Me.RaiseDataMemberChanged("Photo")
                    Me.OnPhotoChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'PhotoPath' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(255)>  _
        Public Property PhotoPath() As String
            Get
                Return Me._photoPath
            End Get
            Set
                If (String.Equals(Me._photoPath, value) = false) Then
                    Me.OnPhotoPathChanging(value)
                    Me.RaiseDataMemberChanging("PhotoPath")
                    Me.ValidateProperty("PhotoPath", value)
                    Me._photoPath = value
                    Me.RaiseDataMemberChanged("PhotoPath")
                    Me.OnPhotoPathChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'PostalCode' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(10)>  _
        Public Property PostalCode() As String
            Get
                Return Me._postalCode
            End Get
            Set
                If (String.Equals(Me._postalCode, value) = false) Then
                    Me.OnPostalCodeChanging(value)
                    Me.RaiseDataMemberChanging("PostalCode")
                    Me.ValidateProperty("PostalCode", value)
                    Me._postalCode = value
                    Me.RaiseDataMemberChanged("PostalCode")
                    Me.OnPostalCodeChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Region' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property Region() As String
            Get
                Return Me._region
            End Get
            Set
                If (String.Equals(Me._region, value) = false) Then
                    Me.OnRegionChanging(value)
                    Me.RaiseDataMemberChanging("Region")
                    Me.ValidateProperty("Region", value)
                    Me._region = value
                    Me.RaiseDataMemberChanged("Region")
                    Me.OnRegionChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ReportsTo' value.
        ''' </summary>
        <DataMember(),  _
         RoundtripOriginal()>  _
        Public Property ReportsTo() As Nullable(Of Integer)
            Get
                Return Me._reportsTo
            End Get
            Set
                If (Me._reportsTo.Equals(value) = false) Then
                    Me.OnReportsToChanging(value)
                    Me.RaiseDataMemberChanging("ReportsTo")
                    Me.ValidateProperty("ReportsTo", value)
                    Me._reportsTo = value
                    Me.RaiseDataMemberChanged("ReportsTo")
                    Me.OnReportsToChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Title' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(30)>  _
        Public Property Title() As String
            Get
                Return Me._title
            End Get
            Set
                If (String.Equals(Me._title, value) = false) Then
                    Me.OnTitleChanging(value)
                    Me.RaiseDataMemberChanging("Title")
                    Me.ValidateProperty("Title", value)
                    Me._title = value
                    Me.RaiseDataMemberChanged("Title")
                    Me.OnTitleChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'TitleOfCourtesy' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(25)>  _
        Public Property TitleOfCourtesy() As String
            Get
                Return Me._titleOfCourtesy
            End Get
            Set
                If (String.Equals(Me._titleOfCourtesy, value) = false) Then
                    Me.OnTitleOfCourtesyChanging(value)
                    Me.RaiseDataMemberChanging("TitleOfCourtesy")
                    Me.ValidateProperty("TitleOfCourtesy", value)
                    Me._titleOfCourtesy = value
                    Me.RaiseDataMemberChanged("TitleOfCourtesy")
                    Me.OnTitleOfCourtesyChanged
                End If
            End Set
        End Property
        
        Private Function FilterEmployee1(ByVal entity As Employee) As Boolean
            Return Object.Equals(entity.EmployeeID, Me.ReportsTo)
        End Function
        
        Private Sub AttachEmployees1(ByVal entity As Employee)
            entity.Employee1 = Me
        End Sub
        
        Private Sub DetachEmployees1(ByVal entity As Employee)
            entity.Employee1 = Nothing
        End Sub
        
        Private Function FilterEmployees1(ByVal entity As Employee) As Boolean
            Return Object.Equals(entity.ReportsTo, Me.EmployeeID)
        End Function
        
        Private Sub AttachOrders(ByVal entity As Order)
            entity.Employee = Me
        End Sub
        
        Private Sub DetachOrders(ByVal entity As Order)
            entity.Employee = Nothing
        End Sub
        
        Private Function FilterOrders(ByVal entity As Order) As Boolean
            Return Object.Equals(entity.EmployeeID, Me.EmployeeID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._employeeID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Order' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Order
        Inherits Entity
        
        Private _customer As EntityRef(Of Customer)
        
        Private _customerID As String
        
        Private _employee As EntityRef(Of Employee)
        
        Private _employeeID As Nullable(Of Integer)
        
        Private _freight As Nullable(Of Decimal)
        
        Private _order_Details As EntityCollection(Of Order_Detail)
        
        Private _orderDate As Nullable(Of DateTime)
        
        Private _orderID As Integer
        
        Private _requiredDate As Nullable(Of DateTime)
        
        Private _shipAddress As String
        
        Private _shipCity As String
        
        Private _shipCountry As String
        
        Private _shipName As String
        
        Private _shippedDate As Nullable(Of DateTime)
        
        Private _shipper As EntityRef(Of Shipper)
        
        Private _shipPostalCode As String
        
        Private _shipRegion As String
        
        Private _shipVia As Nullable(Of Integer)
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnCustomerIDChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCustomerIDChanged()
        End Sub
        Private Partial Sub OnEmployeeIDChanging(ByVal value As Nullable(Of Integer))
        End Sub
        Private Partial Sub OnEmployeeIDChanged()
        End Sub
        Private Partial Sub OnFreightChanging(ByVal value As Nullable(Of Decimal))
        End Sub
        Private Partial Sub OnFreightChanged()
        End Sub
        Private Partial Sub OnOrderDateChanging(ByVal value As Nullable(Of DateTime))
        End Sub
        Private Partial Sub OnOrderDateChanged()
        End Sub
        Private Partial Sub OnOrderIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnOrderIDChanged()
        End Sub
        Private Partial Sub OnRequiredDateChanging(ByVal value As Nullable(Of DateTime))
        End Sub
        Private Partial Sub OnRequiredDateChanged()
        End Sub
        Private Partial Sub OnShipAddressChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnShipAddressChanged()
        End Sub
        Private Partial Sub OnShipCityChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnShipCityChanged()
        End Sub
        Private Partial Sub OnShipCountryChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnShipCountryChanged()
        End Sub
        Private Partial Sub OnShipNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnShipNameChanged()
        End Sub
        Private Partial Sub OnShippedDateChanging(ByVal value As Nullable(Of DateTime))
        End Sub
        Private Partial Sub OnShippedDateChanged()
        End Sub
        Private Partial Sub OnShipPostalCodeChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnShipPostalCodeChanged()
        End Sub
        Private Partial Sub OnShipRegionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnShipRegionChanged()
        End Sub
        Private Partial Sub OnShipViaChanging(ByVal value As Nullable(Of Integer))
        End Sub
        Private Partial Sub OnShipViaChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Order"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Customer"/> entity.
        ''' </summary>
        <Association("Customer_Order", "CustomerID", "CustomerID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Customer() As Customer
            Get
                If (Me._customer Is Nothing) Then
                    Me._customer = New EntityRef(Of Customer)(Me, "Customer", AddressOf Me.FilterCustomer)
                End If
                Return Me._customer.Entity
            End Get
            Set
                Dim previous As Customer = Me.Customer
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Customer", value)
                    If (Not (previous) Is Nothing) Then
                        Me._customer.Entity = Nothing
                        previous.Orders.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.CustomerID = value.CustomerID
                    Else
                        Me.CustomerID = CType(Nothing, String)
                    End If
                    Me._customer.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Orders.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Customer")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'CustomerID' value.
        ''' </summary>
        <DataMember(),  _
         RoundtripOriginal(),  _
         StringLength(5)>  _
        Public Property CustomerID() As String
            Get
                Return Me._customerID
            End Get
            Set
                If (String.Equals(Me._customerID, value) = false) Then
                    Me.OnCustomerIDChanging(value)
                    Me.RaiseDataMemberChanging("CustomerID")
                    Me.ValidateProperty("CustomerID", value)
                    Me._customerID = value
                    Me.RaiseDataMemberChanged("CustomerID")
                    Me.OnCustomerIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Employee"/> entity.
        ''' </summary>
        <Association("Employee_Order", "EmployeeID", "EmployeeID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Employee() As Employee
            Get
                If (Me._employee Is Nothing) Then
                    Me._employee = New EntityRef(Of Employee)(Me, "Employee", AddressOf Me.FilterEmployee)
                End If
                Return Me._employee.Entity
            End Get
            Set
                Dim previous As Employee = Me.Employee
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Employee", value)
                    If (Not (previous) Is Nothing) Then
                        Me._employee.Entity = Nothing
                        previous.Orders.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.EmployeeID = value.EmployeeID
                    Else
                        Me.EmployeeID = CType(Nothing, Nullable(Of Integer))
                    End If
                    Me._employee.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Orders.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Employee")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'EmployeeID' value.
        ''' </summary>
        <DataMember(),  _
         RoundtripOriginal()>  _
        Public Property EmployeeID() As Nullable(Of Integer)
            Get
                Return Me._employeeID
            End Get
            Set
                If (Me._employeeID.Equals(value) = false) Then
                    Me.OnEmployeeIDChanging(value)
                    Me.RaiseDataMemberChanging("EmployeeID")
                    Me.ValidateProperty("EmployeeID", value)
                    Me._employeeID = value
                    Me.RaiseDataMemberChanged("EmployeeID")
                    Me.OnEmployeeIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Freight' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Freight() As Nullable(Of Decimal)
            Get
                Return Me._freight
            End Get
            Set
                If (Me._freight.Equals(value) = false) Then
                    Me.OnFreightChanging(value)
                    Me.RaiseDataMemberChanging("Freight")
                    Me.ValidateProperty("Freight", value)
                    Me._freight = value
                    Me.RaiseDataMemberChanged("Freight")
                    Me.OnFreightChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Order_Detail"/> entity instances.
        ''' </summary>
        <Association("Order_Order_Detail", "OrderID", "OrderID"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Order_Details() As EntityCollection(Of Order_Detail)
            Get
                If (Me._order_Details Is Nothing) Then
                    Me._order_Details = New EntityCollection(Of Order_Detail)(Me, "Order_Details", AddressOf Me.FilterOrder_Details, AddressOf Me.AttachOrder_Details, AddressOf Me.DetachOrder_Details)
                End If
                Return Me._order_Details
            End Get
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'OrderDate' value.
        ''' </summary>
        <DataMember()>  _
        Public Property OrderDate() As Nullable(Of DateTime)
            Get
                Return Me._orderDate
            End Get
            Set
                If (Me._orderDate.Equals(value) = false) Then
                    Me.OnOrderDateChanging(value)
                    Me.RaiseDataMemberChanging("OrderDate")
                    Me.ValidateProperty("OrderDate", value)
                    Me._orderDate = value
                    Me.RaiseDataMemberChanged("OrderDate")
                    Me.OnOrderDateChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'OrderID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property OrderID() As Integer
            Get
                Return Me._orderID
            End Get
            Set
                If ((Me._orderID = value)  _
                            = false) Then
                    Me.OnOrderIDChanging(value)
                    Me.ValidateProperty("OrderID", value)
                    Me._orderID = value
                    Me.RaisePropertyChanged("OrderID")
                    Me.OnOrderIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'RequiredDate' value.
        ''' </summary>
        <DataMember()>  _
        Public Property RequiredDate() As Nullable(Of DateTime)
            Get
                Return Me._requiredDate
            End Get
            Set
                If (Me._requiredDate.Equals(value) = false) Then
                    Me.OnRequiredDateChanging(value)
                    Me.RaiseDataMemberChanging("RequiredDate")
                    Me.ValidateProperty("RequiredDate", value)
                    Me._requiredDate = value
                    Me.RaiseDataMemberChanged("RequiredDate")
                    Me.OnRequiredDateChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipAddress' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(60)>  _
        Public Property ShipAddress() As String
            Get
                Return Me._shipAddress
            End Get
            Set
                If (String.Equals(Me._shipAddress, value) = false) Then
                    Me.OnShipAddressChanging(value)
                    Me.RaiseDataMemberChanging("ShipAddress")
                    Me.ValidateProperty("ShipAddress", value)
                    Me._shipAddress = value
                    Me.RaiseDataMemberChanged("ShipAddress")
                    Me.OnShipAddressChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipCity' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property ShipCity() As String
            Get
                Return Me._shipCity
            End Get
            Set
                If (String.Equals(Me._shipCity, value) = false) Then
                    Me.OnShipCityChanging(value)
                    Me.RaiseDataMemberChanging("ShipCity")
                    Me.ValidateProperty("ShipCity", value)
                    Me._shipCity = value
                    Me.RaiseDataMemberChanged("ShipCity")
                    Me.OnShipCityChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipCountry' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property ShipCountry() As String
            Get
                Return Me._shipCountry
            End Get
            Set
                If (String.Equals(Me._shipCountry, value) = false) Then
                    Me.OnShipCountryChanging(value)
                    Me.RaiseDataMemberChanging("ShipCountry")
                    Me.ValidateProperty("ShipCountry", value)
                    Me._shipCountry = value
                    Me.RaiseDataMemberChanged("ShipCountry")
                    Me.OnShipCountryChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipName' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(40)>  _
        Public Property ShipName() As String
            Get
                Return Me._shipName
            End Get
            Set
                If (String.Equals(Me._shipName, value) = false) Then
                    Me.OnShipNameChanging(value)
                    Me.RaiseDataMemberChanging("ShipName")
                    Me.ValidateProperty("ShipName", value)
                    Me._shipName = value
                    Me.RaiseDataMemberChanged("ShipName")
                    Me.OnShipNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShippedDate' value.
        ''' </summary>
        <DataMember()>  _
        Public Property ShippedDate() As Nullable(Of DateTime)
            Get
                Return Me._shippedDate
            End Get
            Set
                If (Me._shippedDate.Equals(value) = false) Then
                    Me.OnShippedDateChanging(value)
                    Me.RaiseDataMemberChanging("ShippedDate")
                    Me.ValidateProperty("ShippedDate", value)
                    Me._shippedDate = value
                    Me.RaiseDataMemberChanged("ShippedDate")
                    Me.OnShippedDateChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Shipper"/> entity.
        ''' </summary>
        <Association("Shipper_Order", "ShipVia", "ShipperID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Shipper() As Shipper
            Get
                If (Me._shipper Is Nothing) Then
                    Me._shipper = New EntityRef(Of Shipper)(Me, "Shipper", AddressOf Me.FilterShipper)
                End If
                Return Me._shipper.Entity
            End Get
            Set
                Dim previous As Shipper = Me.Shipper
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Shipper", value)
                    If (Not (previous) Is Nothing) Then
                        Me._shipper.Entity = Nothing
                        previous.Orders.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.ShipVia = value.ShipperID
                    Else
                        Me.ShipVia = CType(Nothing, Nullable(Of Integer))
                    End If
                    Me._shipper.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Orders.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Shipper")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipPostalCode' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(10)>  _
        Public Property ShipPostalCode() As String
            Get
                Return Me._shipPostalCode
            End Get
            Set
                If (String.Equals(Me._shipPostalCode, value) = false) Then
                    Me.OnShipPostalCodeChanging(value)
                    Me.RaiseDataMemberChanging("ShipPostalCode")
                    Me.ValidateProperty("ShipPostalCode", value)
                    Me._shipPostalCode = value
                    Me.RaiseDataMemberChanged("ShipPostalCode")
                    Me.OnShipPostalCodeChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipRegion' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property ShipRegion() As String
            Get
                Return Me._shipRegion
            End Get
            Set
                If (String.Equals(Me._shipRegion, value) = false) Then
                    Me.OnShipRegionChanging(value)
                    Me.RaiseDataMemberChanging("ShipRegion")
                    Me.ValidateProperty("ShipRegion", value)
                    Me._shipRegion = value
                    Me.RaiseDataMemberChanged("ShipRegion")
                    Me.OnShipRegionChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipVia' value.
        ''' </summary>
        <DataMember(),  _
         RoundtripOriginal()>  _
        Public Property ShipVia() As Nullable(Of Integer)
            Get
                Return Me._shipVia
            End Get
            Set
                If (Me._shipVia.Equals(value) = false) Then
                    Me.OnShipViaChanging(value)
                    Me.RaiseDataMemberChanging("ShipVia")
                    Me.ValidateProperty("ShipVia", value)
                    Me._shipVia = value
                    Me.RaiseDataMemberChanged("ShipVia")
                    Me.OnShipViaChanged
                End If
            End Set
        End Property
        
        Private Function FilterCustomer(ByVal entity As Customer) As Boolean
            Return Object.Equals(entity.CustomerID, Me.CustomerID)
        End Function
        
        Private Function FilterEmployee(ByVal entity As Employee) As Boolean
            Return Object.Equals(entity.EmployeeID, Me.EmployeeID)
        End Function
        
        Private Sub AttachOrder_Details(ByVal entity As Order_Detail)
            entity.Order = Me
        End Sub
        
        Private Sub DetachOrder_Details(ByVal entity As Order_Detail)
            entity.Order = Nothing
        End Sub
        
        Private Function FilterOrder_Details(ByVal entity As Order_Detail) As Boolean
            Return Object.Equals(entity.OrderID, Me.OrderID)
        End Function
        
        Private Function FilterShipper(ByVal entity As Shipper) As Boolean
            Return Object.Equals(entity.ShipperID, Me.ShipVia)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._orderID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Order_Detail' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Order_Detail
        Inherits Entity
        
        Private _discount As Single
        
        Private _order As EntityRef(Of Order)
        
        Private _orderID As Integer
        
        Private _product As EntityRef(Of Product)
        
        Private _productID As Integer
        
        Private _quantity As Short
        
        Private _unitPrice As Decimal
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnDiscountChanging(ByVal value As Single)
        End Sub
        Private Partial Sub OnDiscountChanged()
        End Sub
        Private Partial Sub OnOrderIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnOrderIDChanged()
        End Sub
        Private Partial Sub OnProductIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnProductIDChanged()
        End Sub
        Private Partial Sub OnQuantityChanging(ByVal value As Short)
        End Sub
        Private Partial Sub OnQuantityChanged()
        End Sub
        Private Partial Sub OnUnitPriceChanging(ByVal value As Decimal)
        End Sub
        Private Partial Sub OnUnitPriceChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Order_Detail"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'Discount' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Discount() As Single
            Get
                Return Me._discount
            End Get
            Set
                If ((Me._discount = value)  _
                            = false) Then
                    Me.OnDiscountChanging(value)
                    Me.RaiseDataMemberChanging("Discount")
                    Me.ValidateProperty("Discount", value)
                    Me._discount = value
                    Me.RaiseDataMemberChanged("Discount")
                    Me.OnDiscountChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Order"/> entity.
        ''' </summary>
        <Association("Order_Order_Detail", "OrderID", "OrderID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Order() As Order
            Get
                If (Me._order Is Nothing) Then
                    Me._order = New EntityRef(Of Order)(Me, "Order", AddressOf Me.FilterOrder)
                End If
                Return Me._order.Entity
            End Get
            Set
                Dim previous As Order = Me.Order
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Order", value)
                    If (Not (previous) Is Nothing) Then
                        Me._order.Entity = Nothing
                        previous.Order_Details.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.OrderID = value.OrderID
                    Else
                        Me.OrderID = CType(Nothing, Integer)
                    End If
                    Me._order.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Order_Details.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Order")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'OrderID' value.
        ''' </summary>
        <DataMember(),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property OrderID() As Integer
            Get
                Return Me._orderID
            End Get
            Set
                If ((Me._orderID = value)  _
                            = false) Then
                    Me.OnOrderIDChanging(value)
                    Me.RaiseDataMemberChanging("OrderID")
                    Me.ValidateProperty("OrderID", value)
                    Me._orderID = value
                    Me.RaiseDataMemberChanged("OrderID")
                    Me.OnOrderIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Product"/> entity.
        ''' </summary>
        <Association("Product_Order_Detail", "ProductID", "ProductID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Product() As Product
            Get
                If (Me._product Is Nothing) Then
                    Me._product = New EntityRef(Of Product)(Me, "Product", AddressOf Me.FilterProduct)
                End If
                Return Me._product.Entity
            End Get
            Set
                Dim previous As Product = Me.Product
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Product", value)
                    If (Not (previous) Is Nothing) Then
                        Me._product.Entity = Nothing
                        previous.Order_Details.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.ProductID = value.ProductID
                    Else
                        Me.ProductID = CType(Nothing, Integer)
                    End If
                    Me._product.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Order_Details.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Product")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ProductID' value.
        ''' </summary>
        <DataMember(),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property ProductID() As Integer
            Get
                Return Me._productID
            End Get
            Set
                If ((Me._productID = value)  _
                            = false) Then
                    Me.OnProductIDChanging(value)
                    Me.RaiseDataMemberChanging("ProductID")
                    Me.ValidateProperty("ProductID", value)
                    Me._productID = value
                    Me.RaiseDataMemberChanged("ProductID")
                    Me.OnProductIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Quantity' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Quantity() As Short
            Get
                Return Me._quantity
            End Get
            Set
                If ((Me._quantity = value)  _
                            = false) Then
                    Me.OnQuantityChanging(value)
                    Me.RaiseDataMemberChanging("Quantity")
                    Me.ValidateProperty("Quantity", value)
                    Me._quantity = value
                    Me.RaiseDataMemberChanged("Quantity")
                    Me.OnQuantityChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'UnitPrice' value.
        ''' </summary>
        <DataMember()>  _
        Public Property UnitPrice() As Decimal
            Get
                Return Me._unitPrice
            End Get
            Set
                If ((Me._unitPrice = value)  _
                            = false) Then
                    Me.OnUnitPriceChanging(value)
                    Me.RaiseDataMemberChanging("UnitPrice")
                    Me.ValidateProperty("UnitPrice", value)
                    Me._unitPrice = value
                    Me.RaiseDataMemberChanged("UnitPrice")
                    Me.OnUnitPriceChanged
                End If
            End Set
        End Property
        
        Private Function FilterOrder(ByVal entity As Order) As Boolean
            Return Object.Equals(entity.OrderID, Me.OrderID)
        End Function
        
        Private Function FilterProduct(ByVal entity As Product) As Boolean
            Return Object.Equals(entity.ProductID, Me.ProductID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return EntityKey.Create(Me._orderID, Me._productID)
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Product' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Product
        Inherits Entity
        
        Private _category As EntityRef(Of Category)
        
        Private _categoryID As Nullable(Of Integer)
        
        Private _discontinued As Boolean
        
        Private _order_Details As EntityCollection(Of Order_Detail)
        
        Private _productID As Integer
        
        Private _productName As String
        
        Private _quantityPerUnit As String
        
        Private _reorderLevel As Nullable(Of Short)
        
        Private _supplier As EntityRef(Of Supplier)
        
        Private _supplierID As Nullable(Of Integer)
        
        Private _unitPrice As Nullable(Of Decimal)
        
        Private _unitsInStock As Nullable(Of Short)
        
        Private _unitsOnOrder As Nullable(Of Short)
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnCategoryIDChanging(ByVal value As Nullable(Of Integer))
        End Sub
        Private Partial Sub OnCategoryIDChanged()
        End Sub
        Private Partial Sub OnDiscontinuedChanging(ByVal value As Boolean)
        End Sub
        Private Partial Sub OnDiscontinuedChanged()
        End Sub
        Private Partial Sub OnProductIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnProductIDChanged()
        End Sub
        Private Partial Sub OnProductNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnProductNameChanged()
        End Sub
        Private Partial Sub OnQuantityPerUnitChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnQuantityPerUnitChanged()
        End Sub
        Private Partial Sub OnReorderLevelChanging(ByVal value As Nullable(Of Short))
        End Sub
        Private Partial Sub OnReorderLevelChanged()
        End Sub
        Private Partial Sub OnSupplierIDChanging(ByVal value As Nullable(Of Integer))
        End Sub
        Private Partial Sub OnSupplierIDChanged()
        End Sub
        Private Partial Sub OnUnitPriceChanging(ByVal value As Nullable(Of Decimal))
        End Sub
        Private Partial Sub OnUnitPriceChanged()
        End Sub
        Private Partial Sub OnUnitsInStockChanging(ByVal value As Nullable(Of Short))
        End Sub
        Private Partial Sub OnUnitsInStockChanged()
        End Sub
        Private Partial Sub OnUnitsOnOrderChanging(ByVal value As Nullable(Of Short))
        End Sub
        Private Partial Sub OnUnitsOnOrderChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Product"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Category"/> entity.
        ''' </summary>
        <Association("Category_Product", "CategoryID", "CategoryID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Category() As Category
            Get
                If (Me._category Is Nothing) Then
                    Me._category = New EntityRef(Of Category)(Me, "Category", AddressOf Me.FilterCategory)
                End If
                Return Me._category.Entity
            End Get
            Set
                Dim previous As Category = Me.Category
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Category", value)
                    If (Not (previous) Is Nothing) Then
                        Me._category.Entity = Nothing
                        previous.Products.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.CategoryID = value.CategoryID
                    Else
                        Me.CategoryID = CType(Nothing, Nullable(Of Integer))
                    End If
                    Me._category.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Products.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Category")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'CategoryID' value.
        ''' </summary>
        <DataMember(),  _
         RoundtripOriginal()>  _
        Public Property CategoryID() As Nullable(Of Integer)
            Get
                Return Me._categoryID
            End Get
            Set
                If (Me._categoryID.Equals(value) = false) Then
                    Me.OnCategoryIDChanging(value)
                    Me.RaiseDataMemberChanging("CategoryID")
                    Me.ValidateProperty("CategoryID", value)
                    Me._categoryID = value
                    Me.RaiseDataMemberChanged("CategoryID")
                    Me.OnCategoryIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Discontinued' value.
        ''' </summary>
        <DataMember()>  _
        Public Property Discontinued() As Boolean
            Get
                Return Me._discontinued
            End Get
            Set
                If ((Me._discontinued = value)  _
                            = false) Then
                    Me.OnDiscontinuedChanging(value)
                    Me.RaiseDataMemberChanging("Discontinued")
                    Me.ValidateProperty("Discontinued", value)
                    Me._discontinued = value
                    Me.RaiseDataMemberChanged("Discontinued")
                    Me.OnDiscontinuedChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Order_Detail"/> entity instances.
        ''' </summary>
        <Association("Product_Order_Detail", "ProductID", "ProductID"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Order_Details() As EntityCollection(Of Order_Detail)
            Get
                If (Me._order_Details Is Nothing) Then
                    Me._order_Details = New EntityCollection(Of Order_Detail)(Me, "Order_Details", AddressOf Me.FilterOrder_Details, AddressOf Me.AttachOrder_Details, AddressOf Me.DetachOrder_Details)
                End If
                Return Me._order_Details
            End Get
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ProductID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property ProductID() As Integer
            Get
                Return Me._productID
            End Get
            Set
                If ((Me._productID = value)  _
                            = false) Then
                    Me.OnProductIDChanging(value)
                    Me.ValidateProperty("ProductID", value)
                    Me._productID = value
                    Me.RaisePropertyChanged("ProductID")
                    Me.OnProductIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ProductName' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(40)>  _
        Public Property ProductName() As String
            Get
                Return Me._productName
            End Get
            Set
                If (String.Equals(Me._productName, value) = false) Then
                    Me.OnProductNameChanging(value)
                    Me.RaiseDataMemberChanging("ProductName")
                    Me.ValidateProperty("ProductName", value)
                    Me._productName = value
                    Me.RaiseDataMemberChanged("ProductName")
                    Me.OnProductNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'QuantityPerUnit' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(20)>  _
        Public Property QuantityPerUnit() As String
            Get
                Return Me._quantityPerUnit
            End Get
            Set
                If (String.Equals(Me._quantityPerUnit, value) = false) Then
                    Me.OnQuantityPerUnitChanging(value)
                    Me.RaiseDataMemberChanging("QuantityPerUnit")
                    Me.ValidateProperty("QuantityPerUnit", value)
                    Me._quantityPerUnit = value
                    Me.RaiseDataMemberChanged("QuantityPerUnit")
                    Me.OnQuantityPerUnitChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ReorderLevel' value.
        ''' </summary>
        <DataMember()>  _
        Public Property ReorderLevel() As Nullable(Of Short)
            Get
                Return Me._reorderLevel
            End Get
            Set
                If (Me._reorderLevel.Equals(value) = false) Then
                    Me.OnReorderLevelChanging(value)
                    Me.RaiseDataMemberChanging("ReorderLevel")
                    Me.ValidateProperty("ReorderLevel", value)
                    Me._reorderLevel = value
                    Me.RaiseDataMemberChanged("ReorderLevel")
                    Me.OnReorderLevelChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Supplier"/> entity.
        ''' </summary>
        <Association("Supplier_Product", "SupplierID", "SupplierID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Supplier() As Supplier
            Get
                If (Me._supplier Is Nothing) Then
                    Me._supplier = New EntityRef(Of Supplier)(Me, "Supplier", AddressOf Me.FilterSupplier)
                End If
                Return Me._supplier.Entity
            End Get
            Set
                Dim previous As Supplier = Me.Supplier
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Supplier", value)
                    If (Not (previous) Is Nothing) Then
                        Me._supplier.Entity = Nothing
                        previous.Products.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.SupplierID = value.SupplierID
                    Else
                        Me.SupplierID = CType(Nothing, Nullable(Of Integer))
                    End If
                    Me._supplier.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Products.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Supplier")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'SupplierID' value.
        ''' </summary>
        <DataMember(),  _
         RoundtripOriginal()>  _
        Public Property SupplierID() As Nullable(Of Integer)
            Get
                Return Me._supplierID
            End Get
            Set
                If (Me._supplierID.Equals(value) = false) Then
                    Me.OnSupplierIDChanging(value)
                    Me.RaiseDataMemberChanging("SupplierID")
                    Me.ValidateProperty("SupplierID", value)
                    Me._supplierID = value
                    Me.RaiseDataMemberChanged("SupplierID")
                    Me.OnSupplierIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'UnitPrice' value.
        ''' </summary>
        <DataMember()>  _
        Public Property UnitPrice() As Nullable(Of Decimal)
            Get
                Return Me._unitPrice
            End Get
            Set
                If (Me._unitPrice.Equals(value) = false) Then
                    Me.OnUnitPriceChanging(value)
                    Me.RaiseDataMemberChanging("UnitPrice")
                    Me.ValidateProperty("UnitPrice", value)
                    Me._unitPrice = value
                    Me.RaiseDataMemberChanged("UnitPrice")
                    Me.OnUnitPriceChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'UnitsInStock' value.
        ''' </summary>
        <DataMember()>  _
        Public Property UnitsInStock() As Nullable(Of Short)
            Get
                Return Me._unitsInStock
            End Get
            Set
                If (Me._unitsInStock.Equals(value) = false) Then
                    Me.OnUnitsInStockChanging(value)
                    Me.RaiseDataMemberChanging("UnitsInStock")
                    Me.ValidateProperty("UnitsInStock", value)
                    Me._unitsInStock = value
                    Me.RaiseDataMemberChanged("UnitsInStock")
                    Me.OnUnitsInStockChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'UnitsOnOrder' value.
        ''' </summary>
        <DataMember()>  _
        Public Property UnitsOnOrder() As Nullable(Of Short)
            Get
                Return Me._unitsOnOrder
            End Get
            Set
                If (Me._unitsOnOrder.Equals(value) = false) Then
                    Me.OnUnitsOnOrderChanging(value)
                    Me.RaiseDataMemberChanging("UnitsOnOrder")
                    Me.ValidateProperty("UnitsOnOrder", value)
                    Me._unitsOnOrder = value
                    Me.RaiseDataMemberChanged("UnitsOnOrder")
                    Me.OnUnitsOnOrderChanged
                End If
            End Set
        End Property
        
        Private Function FilterCategory(ByVal entity As Category) As Boolean
            Return Object.Equals(entity.CategoryID, Me.CategoryID)
        End Function
        
        Private Sub AttachOrder_Details(ByVal entity As Order_Detail)
            entity.Product = Me
        End Sub
        
        Private Sub DetachOrder_Details(ByVal entity As Order_Detail)
            entity.Product = Nothing
        End Sub
        
        Private Function FilterOrder_Details(ByVal entity As Order_Detail) As Boolean
            Return Object.Equals(entity.ProductID, Me.ProductID)
        End Function
        
        Private Function FilterSupplier(ByVal entity As Supplier) As Boolean
            Return Object.Equals(entity.SupplierID, Me.SupplierID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._productID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Region' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Region
        Inherits Entity
        
        Private _regionDescription As String
        
        Private _regionID As Integer
        
        Private _territories As EntityCollection(Of Territory)
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnRegionDescriptionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnRegionDescriptionChanged()
        End Sub
        Private Partial Sub OnRegionIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnRegionIDChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Region"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'RegionDescription' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(50)>  _
        Public Property RegionDescription() As String
            Get
                Return Me._regionDescription
            End Get
            Set
                If (String.Equals(Me._regionDescription, value) = false) Then
                    Me.OnRegionDescriptionChanging(value)
                    Me.RaiseDataMemberChanging("RegionDescription")
                    Me.ValidateProperty("RegionDescription", value)
                    Me._regionDescription = value
                    Me.RaiseDataMemberChanged("RegionDescription")
                    Me.OnRegionDescriptionChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'RegionID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property RegionID() As Integer
            Get
                Return Me._regionID
            End Get
            Set
                If ((Me._regionID = value)  _
                            = false) Then
                    Me.OnRegionIDChanging(value)
                    Me.ValidateProperty("RegionID", value)
                    Me._regionID = value
                    Me.RaisePropertyChanged("RegionID")
                    Me.OnRegionIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Territory"/> entity instances.
        ''' </summary>
        <Association("Region_Territory", "RegionID", "RegionID"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Territories() As EntityCollection(Of Territory)
            Get
                If (Me._territories Is Nothing) Then
                    Me._territories = New EntityCollection(Of Territory)(Me, "Territories", AddressOf Me.FilterTerritories, AddressOf Me.AttachTerritories, AddressOf Me.DetachTerritories)
                End If
                Return Me._territories
            End Get
        End Property
        
        Private Sub AttachTerritories(ByVal entity As Territory)
            entity.Region = Me
        End Sub
        
        Private Sub DetachTerritories(ByVal entity As Territory)
            entity.Region = Nothing
        End Sub
        
        Private Function FilterTerritories(ByVal entity As Territory) As Boolean
            Return Object.Equals(entity.RegionID, Me.RegionID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._regionID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Shipper' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Shipper
        Inherits Entity
        
        Private _companyName As String
        
        Private _orders As EntityCollection(Of Order)
        
        Private _phone As String
        
        Private _shipperID As Integer
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnCompanyNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCompanyNameChanged()
        End Sub
        Private Partial Sub OnPhoneChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnPhoneChanged()
        End Sub
        Private Partial Sub OnShipperIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnShipperIDChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Shipper"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'CompanyName' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(40)>  _
        Public Property CompanyName() As String
            Get
                Return Me._companyName
            End Get
            Set
                If (String.Equals(Me._companyName, value) = false) Then
                    Me.OnCompanyNameChanging(value)
                    Me.RaiseDataMemberChanging("CompanyName")
                    Me.ValidateProperty("CompanyName", value)
                    Me._companyName = value
                    Me.RaiseDataMemberChanged("CompanyName")
                    Me.OnCompanyNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Order"/> entity instances.
        ''' </summary>
        <Association("Shipper_Order", "ShipperID", "ShipVia"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Orders() As EntityCollection(Of Order)
            Get
                If (Me._orders Is Nothing) Then
                    Me._orders = New EntityCollection(Of Order)(Me, "Orders", AddressOf Me.FilterOrders, AddressOf Me.AttachOrders, AddressOf Me.DetachOrders)
                End If
                Return Me._orders
            End Get
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Phone' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(24)>  _
        Public Property Phone() As String
            Get
                Return Me._phone
            End Get
            Set
                If (String.Equals(Me._phone, value) = false) Then
                    Me.OnPhoneChanging(value)
                    Me.RaiseDataMemberChanging("Phone")
                    Me.ValidateProperty("Phone", value)
                    Me._phone = value
                    Me.RaiseDataMemberChanged("Phone")
                    Me.OnPhoneChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ShipperID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property ShipperID() As Integer
            Get
                Return Me._shipperID
            End Get
            Set
                If ((Me._shipperID = value)  _
                            = false) Then
                    Me.OnShipperIDChanging(value)
                    Me.ValidateProperty("ShipperID", value)
                    Me._shipperID = value
                    Me.RaisePropertyChanged("ShipperID")
                    Me.OnShipperIDChanged
                End If
            End Set
        End Property
        
        Private Sub AttachOrders(ByVal entity As Order)
            entity.Shipper = Me
        End Sub
        
        Private Sub DetachOrders(ByVal entity As Order)
            entity.Shipper = Nothing
        End Sub
        
        Private Function FilterOrders(ByVal entity As Order) As Boolean
            Return Object.Equals(entity.ShipVia, Me.ShipperID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._shipperID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Supplier' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Supplier
        Inherits Entity
        
        Private _address As String
        
        Private _city As String
        
        Private _companyName As String
        
        Private _contactName As String
        
        Private _contactTitle As String
        
        Private _country As String
        
        Private _fax As String
        
        Private _homePage As String
        
        Private _phone As String
        
        Private _postalCode As String
        
        Private _products As EntityCollection(Of Product)
        
        Private _region As String
        
        Private _supplierID As Integer
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnAddressChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnAddressChanged()
        End Sub
        Private Partial Sub OnCityChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCityChanged()
        End Sub
        Private Partial Sub OnCompanyNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCompanyNameChanged()
        End Sub
        Private Partial Sub OnContactNameChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnContactNameChanged()
        End Sub
        Private Partial Sub OnContactTitleChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnContactTitleChanged()
        End Sub
        Private Partial Sub OnCountryChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnCountryChanged()
        End Sub
        Private Partial Sub OnFaxChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnFaxChanged()
        End Sub
        Private Partial Sub OnHomePageChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnHomePageChanged()
        End Sub
        Private Partial Sub OnPhoneChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnPhoneChanged()
        End Sub
        Private Partial Sub OnPostalCodeChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnPostalCodeChanged()
        End Sub
        Private Partial Sub OnRegionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnRegionChanged()
        End Sub
        Private Partial Sub OnSupplierIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnSupplierIDChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Supplier"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the 'Address' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(60)>  _
        Public Property Address() As String
            Get
                Return Me._address
            End Get
            Set
                If (String.Equals(Me._address, value) = false) Then
                    Me.OnAddressChanging(value)
                    Me.RaiseDataMemberChanging("Address")
                    Me.ValidateProperty("Address", value)
                    Me._address = value
                    Me.RaiseDataMemberChanged("Address")
                    Me.OnAddressChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'City' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property City() As String
            Get
                Return Me._city
            End Get
            Set
                If (String.Equals(Me._city, value) = false) Then
                    Me.OnCityChanging(value)
                    Me.RaiseDataMemberChanging("City")
                    Me.ValidateProperty("City", value)
                    Me._city = value
                    Me.RaiseDataMemberChanged("City")
                    Me.OnCityChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'CompanyName' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(40)>  _
        Public Property CompanyName() As String
            Get
                Return Me._companyName
            End Get
            Set
                If (String.Equals(Me._companyName, value) = false) Then
                    Me.OnCompanyNameChanging(value)
                    Me.RaiseDataMemberChanging("CompanyName")
                    Me.ValidateProperty("CompanyName", value)
                    Me._companyName = value
                    Me.RaiseDataMemberChanged("CompanyName")
                    Me.OnCompanyNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ContactName' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(30)>  _
        Public Property ContactName() As String
            Get
                Return Me._contactName
            End Get
            Set
                If (String.Equals(Me._contactName, value) = false) Then
                    Me.OnContactNameChanging(value)
                    Me.RaiseDataMemberChanging("ContactName")
                    Me.ValidateProperty("ContactName", value)
                    Me._contactName = value
                    Me.RaiseDataMemberChanged("ContactName")
                    Me.OnContactNameChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'ContactTitle' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(30)>  _
        Public Property ContactTitle() As String
            Get
                Return Me._contactTitle
            End Get
            Set
                If (String.Equals(Me._contactTitle, value) = false) Then
                    Me.OnContactTitleChanging(value)
                    Me.RaiseDataMemberChanging("ContactTitle")
                    Me.ValidateProperty("ContactTitle", value)
                    Me._contactTitle = value
                    Me.RaiseDataMemberChanged("ContactTitle")
                    Me.OnContactTitleChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Country' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property Country() As String
            Get
                Return Me._country
            End Get
            Set
                If (String.Equals(Me._country, value) = false) Then
                    Me.OnCountryChanging(value)
                    Me.RaiseDataMemberChanging("Country")
                    Me.ValidateProperty("Country", value)
                    Me._country = value
                    Me.RaiseDataMemberChanged("Country")
                    Me.OnCountryChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Fax' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(24)>  _
        Public Property Fax() As String
            Get
                Return Me._fax
            End Get
            Set
                If (String.Equals(Me._fax, value) = false) Then
                    Me.OnFaxChanging(value)
                    Me.RaiseDataMemberChanging("Fax")
                    Me.ValidateProperty("Fax", value)
                    Me._fax = value
                    Me.RaiseDataMemberChanged("Fax")
                    Me.OnFaxChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'HomePage' value.
        ''' </summary>
        <DataMember()>  _
        Public Property HomePage() As String
            Get
                Return Me._homePage
            End Get
            Set
                If (String.Equals(Me._homePage, value) = false) Then
                    Me.OnHomePageChanging(value)
                    Me.RaiseDataMemberChanging("HomePage")
                    Me.ValidateProperty("HomePage", value)
                    Me._homePage = value
                    Me.RaiseDataMemberChanged("HomePage")
                    Me.OnHomePageChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Phone' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(24)>  _
        Public Property Phone() As String
            Get
                Return Me._phone
            End Get
            Set
                If (String.Equals(Me._phone, value) = false) Then
                    Me.OnPhoneChanging(value)
                    Me.RaiseDataMemberChanging("Phone")
                    Me.ValidateProperty("Phone", value)
                    Me._phone = value
                    Me.RaiseDataMemberChanged("Phone")
                    Me.OnPhoneChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'PostalCode' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(10)>  _
        Public Property PostalCode() As String
            Get
                Return Me._postalCode
            End Get
            Set
                If (String.Equals(Me._postalCode, value) = false) Then
                    Me.OnPostalCodeChanging(value)
                    Me.RaiseDataMemberChanging("PostalCode")
                    Me.ValidateProperty("PostalCode", value)
                    Me._postalCode = value
                    Me.RaiseDataMemberChanged("PostalCode")
                    Me.OnPostalCodeChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets the collection of associated <see cref="Product"/> entity instances.
        ''' </summary>
        <Association("Supplier_Product", "SupplierID", "SupplierID"),  _
         XmlIgnore()>  _
        Public ReadOnly Property Products() As EntityCollection(Of Product)
            Get
                If (Me._products Is Nothing) Then
                    Me._products = New EntityCollection(Of Product)(Me, "Products", AddressOf Me.FilterProducts, AddressOf Me.AttachProducts, AddressOf Me.DetachProducts)
                End If
                Return Me._products
            End Get
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'Region' value.
        ''' </summary>
        <DataMember(),  _
         StringLength(15)>  _
        Public Property Region() As String
            Get
                Return Me._region
            End Get
            Set
                If (String.Equals(Me._region, value) = false) Then
                    Me.OnRegionChanging(value)
                    Me.RaiseDataMemberChanging("Region")
                    Me.ValidateProperty("Region", value)
                    Me._region = value
                    Me.RaiseDataMemberChanged("Region")
                    Me.OnRegionChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'SupplierID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         RoundtripOriginal()>  _
        Public Property SupplierID() As Integer
            Get
                Return Me._supplierID
            End Get
            Set
                If ((Me._supplierID = value)  _
                            = false) Then
                    Me.OnSupplierIDChanging(value)
                    Me.ValidateProperty("SupplierID", value)
                    Me._supplierID = value
                    Me.RaisePropertyChanged("SupplierID")
                    Me.OnSupplierIDChanged
                End If
            End Set
        End Property
        
        Private Sub AttachProducts(ByVal entity As Product)
            entity.Supplier = Me
        End Sub
        
        Private Sub DetachProducts(ByVal entity As Product)
            entity.Supplier = Nothing
        End Sub
        
        Private Function FilterProducts(ByVal entity As Product) As Boolean
            Return Object.Equals(entity.SupplierID, Me.SupplierID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._supplierID
        End Function
    End Class
    
    ''' <summary>
    ''' The 'Territory' entity class.
    ''' </summary>
    <DataContract([Namespace]:="http://schemas.datacontract.org/2004/07/TutorialsSilverlight.Web")>  _
    Partial Public NotInheritable Class Territory
        Inherits Entity
        
        Private _region As EntityRef(Of Region)
        
        Private _regionID As Integer
        
        Private _territoryDescription As String
        
        Private _territoryID As String
        
        #Region "Extensibility Method Definitions"

        ''' <summary>
        ''' This method is invoked from the constructor once initialization is complete and
        ''' can be used for further object setup.
        ''' </summary>
        Private Partial Sub OnCreated()
        End Sub
        Private Partial Sub OnRegionIDChanging(ByVal value As Integer)
        End Sub
        Private Partial Sub OnRegionIDChanged()
        End Sub
        Private Partial Sub OnTerritoryDescriptionChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnTerritoryDescriptionChanged()
        End Sub
        Private Partial Sub OnTerritoryIDChanging(ByVal value As String)
        End Sub
        Private Partial Sub OnTerritoryIDChanged()
        End Sub

        #End Region
        
        
        ''' <summary>
        ''' Initializes a new instance of the <see cref="Territory"/> class.
        ''' </summary>
        Public Sub New()
            MyBase.New
            Me.OnCreated
        End Sub
        
        ''' <summary>
        ''' Gets or sets the associated <see cref="Region"/> entity.
        ''' </summary>
        <Association("Region_Territory", "RegionID", "RegionID", IsForeignKey:=true),  _
         XmlIgnore()>  _
        Public Property Region() As Region
            Get
                If (Me._region Is Nothing) Then
                    Me._region = New EntityRef(Of Region)(Me, "Region", AddressOf Me.FilterRegion)
                End If
                Return Me._region.Entity
            End Get
            Set
                Dim previous As Region = Me.Region
                If (Object.Equals(previous, value) = false) Then
                    Me.ValidateProperty("Region", value)
                    If (Not (previous) Is Nothing) Then
                        Me._region.Entity = Nothing
                        previous.Territories.Remove(Me)
                    End If
                    If (Not (value) Is Nothing) Then
                        Me.RegionID = value.RegionID
                    Else
                        Me.RegionID = CType(Nothing, Integer)
                    End If
                    Me._region.Entity = value
                    If (Not (value) Is Nothing) Then
                        value.Territories.Add(Me)
                    End If
                    Me.RaisePropertyChanged("Region")
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'RegionID' value.
        ''' </summary>
        <DataMember(),  _
         RoundtripOriginal()>  _
        Public Property RegionID() As Integer
            Get
                Return Me._regionID
            End Get
            Set
                If ((Me._regionID = value)  _
                            = false) Then
                    Me.OnRegionIDChanging(value)
                    Me.RaiseDataMemberChanging("RegionID")
                    Me.ValidateProperty("RegionID", value)
                    Me._regionID = value
                    Me.RaiseDataMemberChanged("RegionID")
                    Me.OnRegionIDChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'TerritoryDescription' value.
        ''' </summary>
        <DataMember(),  _
         Required(),  _
         StringLength(50)>  _
        Public Property TerritoryDescription() As String
            Get
                Return Me._territoryDescription
            End Get
            Set
                If (String.Equals(Me._territoryDescription, value) = false) Then
                    Me.OnTerritoryDescriptionChanging(value)
                    Me.RaiseDataMemberChanging("TerritoryDescription")
                    Me.ValidateProperty("TerritoryDescription", value)
                    Me._territoryDescription = value
                    Me.RaiseDataMemberChanged("TerritoryDescription")
                    Me.OnTerritoryDescriptionChanged
                End If
            End Set
        End Property
        
        ''' <summary>
        ''' Gets or sets the 'TerritoryID' value.
        ''' </summary>
        <DataMember(),  _
         Editable(false, AllowInitialValue:=true),  _
         Key(),  _
         Required(),  _
         RoundtripOriginal(),  _
         StringLength(20)>  _
        Public Property TerritoryID() As String
            Get
                Return Me._territoryID
            End Get
            Set
                If (String.Equals(Me._territoryID, value) = false) Then
                    Me.OnTerritoryIDChanging(value)
                    Me.ValidateProperty("TerritoryID", value)
                    Me._territoryID = value
                    Me.RaisePropertyChanged("TerritoryID")
                    Me.OnTerritoryIDChanged
                End If
            End Set
        End Property
        
        Private Function FilterRegion(ByVal entity As Region) As Boolean
            Return Object.Equals(entity.RegionID, Me.RegionID)
        End Function
        
        ''' <summary>
        ''' Computes a value from the key fields that uniquely identifies this entity instance.
        ''' </summary>
        ''' <returns>An object instance that uniquely identifies this entity instance.</returns>
        Public Overrides Function GetIdentity() As Object
            Return Me._territoryID
        End Function
    End Class
End Namespace
