
'------------------------------------------------------------------------------
' <auto-generated>
'    This code was generated from a template.
'
'    Manual changes to this file may cause unexpected behavior in your application.
'    Manual changes to this file will be overwritten if the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Imports System
Imports System.Data.Objects
Imports System.Data.Objects.DataClasses
Imports System.Data.EntityClient
Imports System.ComponentModel
Imports System.Xml.Serialization
Imports System.Runtime.Serialization

<Assembly: EdmSchemaAttribute("ec90eba0-2a05-48d4-b6e0-0a54ac9f108c")>
#Region "EDM Relationship Metadata"
<Assembly: EdmRelationshipAttribute("AdventureWorks_DataModel", "FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory", System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, GetType(SalesTerritory), "Customer", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, GetType(Customer), True)>
<Assembly: EdmRelationshipAttribute("AdventureWorks_DataModel", "FK_SalesOrderHeader_Customer_CustomerID", "Customer", System.Data.Metadata.Edm.RelationshipMultiplicity.One, GetType(Customer), "SalesOrderHeader", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, GetType(SalesOrderHeader), True)>
<Assembly: EdmRelationshipAttribute("AdventureWorks_DataModel", "FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader", System.Data.Metadata.Edm.RelationshipMultiplicity.One, GetType(SalesOrderHeader), "SalesOrderDetail", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, GetType(SalesOrderDetail), True)>
<Assembly: EdmRelationshipAttribute("AdventureWorks_DataModel", "FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory", System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, GetType(SalesTerritory), "SalesOrderHeader", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, GetType(SalesOrderHeader), True)>

#End Region

#Region "Contexts"

''' <summary>
''' No Metadata Documentation available.
''' </summary>
Public Partial Class AdventureWorks_DataEntities
    Inherits ObjectContext

    #Region "Constructors"

    ''' <summary>
    ''' Initializes a new AdventureWorks_DataEntities object using the connection string found in the 'AdventureWorks_DataEntities' section of the application configuration file.
    ''' </summary>
    Public Sub New()
        MyBase.New("name=AdventureWorks_DataEntities", "AdventureWorks_DataEntities")
        OnContextCreated()
    End Sub

    ''' <summary>
    ''' Initialize a new AdventureWorks_DataEntities object.
    ''' </summary>
    Public Sub New(ByVal connectionString As String)
        MyBase.New(connectionString, "AdventureWorks_DataEntities")
        OnContextCreated()
    End Sub

    ''' <summary>
    ''' Initialize a new AdventureWorks_DataEntities object.
    ''' </summary>
    Public Sub New(ByVal connection As EntityConnection)
        MyBase.New(connection, "AdventureWorks_DataEntities")
        OnContextCreated()
    End Sub

    #End Region

    #Region "Partial Methods"

    Partial Private Sub OnContextCreated()
    End Sub

    #End Region

    #Region "ObjectSet Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    Public ReadOnly Property Customers() As ObjectSet(Of Customer)
        Get
            If (_Customers Is Nothing) Then
                _Customers = MyBase.CreateObjectSet(Of Customer)("Customers")
            End If
            Return _Customers
        End Get
    End Property

    Private _Customers As ObjectSet(Of Customer)

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    Public ReadOnly Property SalesOrderDetails() As ObjectSet(Of SalesOrderDetail)
        Get
            If (_SalesOrderDetails Is Nothing) Then
                _SalesOrderDetails = MyBase.CreateObjectSet(Of SalesOrderDetail)("SalesOrderDetails")
            End If
            Return _SalesOrderDetails
        End Get
    End Property

    Private _SalesOrderDetails As ObjectSet(Of SalesOrderDetail)

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    Public ReadOnly Property SalesOrderHeaders() As ObjectSet(Of SalesOrderHeader)
        Get
            If (_SalesOrderHeaders Is Nothing) Then
                _SalesOrderHeaders = MyBase.CreateObjectSet(Of SalesOrderHeader)("SalesOrderHeaders")
            End If
            Return _SalesOrderHeaders
        End Get
    End Property

    Private _SalesOrderHeaders As ObjectSet(Of SalesOrderHeader)

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    Public ReadOnly Property SalesTerritories() As ObjectSet(Of SalesTerritory)
        Get
            If (_SalesTerritories Is Nothing) Then
                _SalesTerritories = MyBase.CreateObjectSet(Of SalesTerritory)("SalesTerritories")
            End If
            Return _SalesTerritories
        End Get
    End Property

    Private _SalesTerritories As ObjectSet(Of SalesTerritory)

    #End Region
    #Region "AddTo Methods"

    ''' <summary>
    ''' Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet(Of T) property instead.
    ''' </summary>
    Public Sub AddToCustomers(ByVal customer As Customer)
        MyBase.AddObject("Customers", customer)
    End Sub

    ''' <summary>
    ''' Deprecated Method for adding a new object to the SalesOrderDetails EntitySet. Consider using the .Add method of the associated ObjectSet(Of T) property instead.
    ''' </summary>
    Public Sub AddToSalesOrderDetails(ByVal salesOrderDetail As SalesOrderDetail)
        MyBase.AddObject("SalesOrderDetails", salesOrderDetail)
    End Sub

    ''' <summary>
    ''' Deprecated Method for adding a new object to the SalesOrderHeaders EntitySet. Consider using the .Add method of the associated ObjectSet(Of T) property instead.
    ''' </summary>
    Public Sub AddToSalesOrderHeaders(ByVal salesOrderHeader As SalesOrderHeader)
        MyBase.AddObject("SalesOrderHeaders", salesOrderHeader)
    End Sub

    ''' <summary>
    ''' Deprecated Method for adding a new object to the SalesTerritories EntitySet. Consider using the .Add method of the associated ObjectSet(Of T) property instead.
    ''' </summary>
    Public Sub AddToSalesTerritories(ByVal salesTerritory As SalesTerritory)
        MyBase.AddObject("SalesTerritories", salesTerritory)
    End Sub

    #End Region
End Class

#End Region
#Region "Entities"

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmEntityTypeAttribute(NamespaceName:="AdventureWorks_DataModel", Name:="Customer")>
<Serializable()>
<DataContractAttribute(IsReference:=True)>
<KnownTypeAttribute(GetType(IndividualCustomer))>
Public Partial Class Customer
    Inherits EntityObject
    #Region "Factory Method"

    ''' <summary>
    ''' Create a new Customer object.
    ''' </summary>
    ''' <param name="customerID">Initial value of the CustomerID property.</param>
    ''' <param name="accountNumber">Initial value of the AccountNumber property.</param>
    ''' <param name="rowguid">Initial value of the rowguid property.</param>
    ''' <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
    Public Shared Function CreateCustomer(customerID As Global.System.Int32, accountNumber As Global.System.String, rowguid As Global.System.Guid, modifiedDate As Global.System.DateTime) As Customer
        Dim customer as Customer = New Customer
        customer.CustomerID = customerID
        customer.AccountNumber = accountNumber
        customer.rowguid = rowguid
        customer.ModifiedDate = modifiedDate
        Return customer
    End Function

    #End Region
    #Region "Primitive Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=true, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property CustomerID() As Global.System.Int32
        Get
            Return _CustomerID
        End Get
        Set
            If (_CustomerID <> Value) Then
                OnCustomerIDChanging(value)
                ReportPropertyChanging("CustomerID")
                _CustomerID = StructuralObject.SetValidValue(value)
                ReportPropertyChanged("CustomerID")
                OnCustomerIDChanged()
            End If
        End Set
    End Property

    Private _CustomerID As Global.System.Int32
    Private Partial Sub OnCustomerIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnCustomerIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property TerritoryID() As Nullable(Of Global.System.Int32)
        Get
            Return _TerritoryID
        End Get
        Set
            OnTerritoryIDChanging(value)
            ReportPropertyChanging("TerritoryID")
            _TerritoryID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("TerritoryID")
            OnTerritoryIDChanged()
        End Set
    End Property

    Private _TerritoryID As Nullable(Of Global.System.Int32)
    Private Partial Sub OnTerritoryIDChanging(value As Nullable(Of Global.System.Int32))
    End Sub

    Private Partial Sub OnTerritoryIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property AccountNumber() As Global.System.String
        Get
            Return _AccountNumber
        End Get
        Set
            OnAccountNumberChanging(value)
            ReportPropertyChanging("AccountNumber")
            _AccountNumber = StructuralObject.SetValidValue(value, false)
            ReportPropertyChanged("AccountNumber")
            OnAccountNumberChanged()
        End Set
    End Property

    Private _AccountNumber As Global.System.String
    Private Partial Sub OnAccountNumberChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnAccountNumberChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property rowguid() As Global.System.Guid
        Get
            Return _rowguid
        End Get
        Set
            OnrowguidChanging(value)
            ReportPropertyChanging("rowguid")
            _rowguid = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("rowguid")
            OnrowguidChanged()
        End Set
    End Property

    Private _rowguid As Global.System.Guid
    Private Partial Sub OnrowguidChanging(value As Global.System.Guid)
    End Sub

    Private Partial Sub OnrowguidChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ModifiedDate() As Global.System.DateTime
        Get
            Return _ModifiedDate
        End Get
        Set
            OnModifiedDateChanging(value)
            ReportPropertyChanging("ModifiedDate")
            _ModifiedDate = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ModifiedDate")
            OnModifiedDateChanged()
        End Set
    End Property

    Private _ModifiedDate As Global.System.DateTime
    Private Partial Sub OnModifiedDateChanging(value As Global.System.DateTime)
    End Sub

    Private Partial Sub OnModifiedDateChanged()
    End Sub

    #End Region
    #Region "Navigation Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory")>
    Public Property SalesTerritory() As SalesTerritory
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory").Value
        End Get
        Set
            CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory").Value = value
        End Set
    End Property
    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <BrowsableAttribute(False)>
    <DataMemberAttribute()>
    Public Property SalesTerritoryReference() As EntityReference(Of SalesTerritory)
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory", value)
            End If
        End Set
    End Property

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_SalesOrderHeader_Customer_CustomerID", "SalesOrderHeader")>
     Public Property SalesOrderHeaders() As EntityCollection(Of SalesOrderHeader)
        Get
            Return CType(Me,IEntityWithRelationships).RelationshipManager.GetRelatedCollection(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderHeader_Customer_CustomerID", "SalesOrderHeader")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedCollection(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderHeader_Customer_CustomerID", "SalesOrderHeader", value)
            End If
        End Set
    End Property

    #End Region
End Class

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmEntityTypeAttribute(NamespaceName:="AdventureWorks_DataModel", Name:="IndividualCustomer")>
<Serializable()>
<DataContractAttribute(IsReference:=True)>
Public Partial Class IndividualCustomer
    Inherits Customer
    #Region "Factory Method"

    ''' <summary>
    ''' Create a new IndividualCustomer object.
    ''' </summary>
    ''' <param name="customerID">Initial value of the CustomerID property.</param>
    ''' <param name="accountNumber">Initial value of the AccountNumber property.</param>
    ''' <param name="rowguid">Initial value of the rowguid property.</param>
    ''' <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
    Public Shared Function CreateIndividualCustomer(customerID As Global.System.Int32, accountNumber As Global.System.String, rowguid As Global.System.Guid, modifiedDate As Global.System.DateTime) As IndividualCustomer
        Dim individualCustomer as IndividualCustomer = New IndividualCustomer
        individualCustomer.CustomerID = customerID
        individualCustomer.AccountNumber = accountNumber
        individualCustomer.rowguid = rowguid
        individualCustomer.ModifiedDate = modifiedDate
        Return individualCustomer
    End Function

    #End Region
End Class

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmEntityTypeAttribute(NamespaceName:="AdventureWorks_DataModel", Name:="SalesOrderDetail")>
<Serializable()>
<DataContractAttribute(IsReference:=True)>
Public Partial Class SalesOrderDetail
    Inherits EntityObject
    #Region "Factory Method"

    ''' <summary>
    ''' Create a new SalesOrderDetail object.
    ''' </summary>
    ''' <param name="salesOrderID">Initial value of the SalesOrderID property.</param>
    ''' <param name="salesOrderDetailID">Initial value of the SalesOrderDetailID property.</param>
    ''' <param name="orderQty">Initial value of the OrderQty property.</param>
    ''' <param name="productID">Initial value of the ProductID property.</param>
    ''' <param name="specialOfferID">Initial value of the SpecialOfferID property.</param>
    ''' <param name="unitPrice">Initial value of the UnitPrice property.</param>
    ''' <param name="unitPriceDiscount">Initial value of the UnitPriceDiscount property.</param>
    ''' <param name="lineTotal">Initial value of the LineTotal property.</param>
    ''' <param name="rowguid">Initial value of the rowguid property.</param>
    ''' <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
    Public Shared Function CreateSalesOrderDetail(salesOrderID As Global.System.Int32, salesOrderDetailID As Global.System.Int32, orderQty As Global.System.Int16, productID As Global.System.Int32, specialOfferID As Global.System.Int32, unitPrice As Global.System.Decimal, unitPriceDiscount As Global.System.Decimal, lineTotal As Global.System.Decimal, rowguid As Global.System.Guid, modifiedDate As Global.System.DateTime) As SalesOrderDetail
        Dim salesOrderDetail as SalesOrderDetail = New SalesOrderDetail
        salesOrderDetail.SalesOrderID = salesOrderID
        salesOrderDetail.SalesOrderDetailID = salesOrderDetailID
        salesOrderDetail.OrderQty = orderQty
        salesOrderDetail.ProductID = productID
        salesOrderDetail.SpecialOfferID = specialOfferID
        salesOrderDetail.UnitPrice = unitPrice
        salesOrderDetail.UnitPriceDiscount = unitPriceDiscount
        salesOrderDetail.LineTotal = lineTotal
        salesOrderDetail.rowguid = rowguid
        salesOrderDetail.ModifiedDate = modifiedDate
        Return salesOrderDetail
    End Function

    #End Region
    #Region "Primitive Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=true, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SalesOrderID() As Global.System.Int32
        Get
            Return _SalesOrderID
        End Get
        Set
            If (_SalesOrderID <> Value) Then
                OnSalesOrderIDChanging(value)
                ReportPropertyChanging("SalesOrderID")
                _SalesOrderID = StructuralObject.SetValidValue(value)
                ReportPropertyChanged("SalesOrderID")
                OnSalesOrderIDChanged()
            End If
        End Set
    End Property

    Private _SalesOrderID As Global.System.Int32
    Private Partial Sub OnSalesOrderIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnSalesOrderIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=true, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SalesOrderDetailID() As Global.System.Int32
        Get
            Return _SalesOrderDetailID
        End Get
        Set
            If (_SalesOrderDetailID <> Value) Then
                OnSalesOrderDetailIDChanging(value)
                ReportPropertyChanging("SalesOrderDetailID")
                _SalesOrderDetailID = StructuralObject.SetValidValue(value)
                ReportPropertyChanged("SalesOrderDetailID")
                OnSalesOrderDetailIDChanged()
            End If
        End Set
    End Property

    Private _SalesOrderDetailID As Global.System.Int32
    Private Partial Sub OnSalesOrderDetailIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnSalesOrderDetailIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property CarrierTrackingNumber() As Global.System.String
        Get
            Return _CarrierTrackingNumber
        End Get
        Set
            OnCarrierTrackingNumberChanging(value)
            ReportPropertyChanging("CarrierTrackingNumber")
            _CarrierTrackingNumber = StructuralObject.SetValidValue(value, true)
            ReportPropertyChanged("CarrierTrackingNumber")
            OnCarrierTrackingNumberChanged()
        End Set
    End Property

    Private _CarrierTrackingNumber As Global.System.String
    Private Partial Sub OnCarrierTrackingNumberChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnCarrierTrackingNumberChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property OrderQty() As Global.System.Int16
        Get
            Return _OrderQty
        End Get
        Set
            OnOrderQtyChanging(value)
            ReportPropertyChanging("OrderQty")
            _OrderQty = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("OrderQty")
            OnOrderQtyChanged()
        End Set
    End Property

    Private _OrderQty As Global.System.Int16
    Private Partial Sub OnOrderQtyChanging(value As Global.System.Int16)
    End Sub

    Private Partial Sub OnOrderQtyChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ProductID() As Global.System.Int32
        Get
            Return _ProductID
        End Get
        Set
            OnProductIDChanging(value)
            ReportPropertyChanging("ProductID")
            _ProductID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ProductID")
            OnProductIDChanged()
        End Set
    End Property

    Private _ProductID As Global.System.Int32
    Private Partial Sub OnProductIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnProductIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SpecialOfferID() As Global.System.Int32
        Get
            Return _SpecialOfferID
        End Get
        Set
            OnSpecialOfferIDChanging(value)
            ReportPropertyChanging("SpecialOfferID")
            _SpecialOfferID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("SpecialOfferID")
            OnSpecialOfferIDChanged()
        End Set
    End Property

    Private _SpecialOfferID As Global.System.Int32
    Private Partial Sub OnSpecialOfferIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnSpecialOfferIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property UnitPrice() As Global.System.Decimal
        Get
            Return _UnitPrice
        End Get
        Set
            OnUnitPriceChanging(value)
            ReportPropertyChanging("UnitPrice")
            _UnitPrice = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("UnitPrice")
            OnUnitPriceChanged()
        End Set
    End Property

    Private _UnitPrice As Global.System.Decimal
    Private Partial Sub OnUnitPriceChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnUnitPriceChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property UnitPriceDiscount() As Global.System.Decimal
        Get
            Return _UnitPriceDiscount
        End Get
        Set
            OnUnitPriceDiscountChanging(value)
            ReportPropertyChanging("UnitPriceDiscount")
            _UnitPriceDiscount = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("UnitPriceDiscount")
            OnUnitPriceDiscountChanged()
        End Set
    End Property

    Private _UnitPriceDiscount As Global.System.Decimal
    Private Partial Sub OnUnitPriceDiscountChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnUnitPriceDiscountChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property LineTotal() As Global.System.Decimal
        Get
            Return _LineTotal
        End Get
        Set
            OnLineTotalChanging(value)
            ReportPropertyChanging("LineTotal")
            _LineTotal = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("LineTotal")
            OnLineTotalChanged()
        End Set
    End Property

    Private _LineTotal As Global.System.Decimal
    Private Partial Sub OnLineTotalChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnLineTotalChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property rowguid() As Global.System.Guid
        Get
            Return _rowguid
        End Get
        Set
            OnrowguidChanging(value)
            ReportPropertyChanging("rowguid")
            _rowguid = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("rowguid")
            OnrowguidChanged()
        End Set
    End Property

    Private _rowguid As Global.System.Guid
    Private Partial Sub OnrowguidChanging(value As Global.System.Guid)
    End Sub

    Private Partial Sub OnrowguidChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ModifiedDate() As Global.System.DateTime
        Get
            Return _ModifiedDate
        End Get
        Set
            OnModifiedDateChanging(value)
            ReportPropertyChanging("ModifiedDate")
            _ModifiedDate = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ModifiedDate")
            OnModifiedDateChanged()
        End Set
    End Property

    Private _ModifiedDate As Global.System.DateTime
    Private Partial Sub OnModifiedDateChanging(value As Global.System.DateTime)
    End Sub

    Private Partial Sub OnModifiedDateChanged()
    End Sub

    #End Region
    #Region "Navigation Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader")>
    Public Property SalesOrderHeader() As SalesOrderHeader
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader").Value
        End Get
        Set
            CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader").Value = value
        End Set
    End Property
    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <BrowsableAttribute(False)>
    <DataMemberAttribute()>
    Public Property SalesOrderHeaderReference() As EntityReference(Of SalesOrderHeader)
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedReference(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader", value)
            End If
        End Set
    End Property

    #End Region
End Class

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmEntityTypeAttribute(NamespaceName:="AdventureWorks_DataModel", Name:="SalesOrderHeader")>
<Serializable()>
<DataContractAttribute(IsReference:=True)>
Public Partial Class SalesOrderHeader
    Inherits EntityObject
    #Region "Factory Method"

    ''' <summary>
    ''' Create a new SalesOrderHeader object.
    ''' </summary>
    ''' <param name="salesOrderID">Initial value of the SalesOrderID property.</param>
    ''' <param name="revisionNumber">Initial value of the RevisionNumber property.</param>
    ''' <param name="orderDate">Initial value of the OrderDate property.</param>
    ''' <param name="dueDate">Initial value of the DueDate property.</param>
    ''' <param name="status">Initial value of the Status property.</param>
    ''' <param name="onlineOrderFlag">Initial value of the OnlineOrderFlag property.</param>
    ''' <param name="salesOrderNumber">Initial value of the SalesOrderNumber property.</param>
    ''' <param name="customerID">Initial value of the CustomerID property.</param>
    ''' <param name="contactID">Initial value of the ContactID property.</param>
    ''' <param name="billToAddressID">Initial value of the BillToAddressID property.</param>
    ''' <param name="shipToAddressID">Initial value of the ShipToAddressID property.</param>
    ''' <param name="shipMethodID">Initial value of the ShipMethodID property.</param>
    ''' <param name="subTotal">Initial value of the SubTotal property.</param>
    ''' <param name="taxAmt">Initial value of the TaxAmt property.</param>
    ''' <param name="freight">Initial value of the Freight property.</param>
    ''' <param name="totalDue">Initial value of the TotalDue property.</param>
    ''' <param name="rowguid">Initial value of the rowguid property.</param>
    ''' <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
    Public Shared Function CreateSalesOrderHeader(salesOrderID As Global.System.Int32, revisionNumber As Global.System.Byte, orderDate As Global.System.DateTime, dueDate As Global.System.DateTime, status As Global.System.Byte, onlineOrderFlag As Global.System.Boolean, salesOrderNumber As Global.System.String, customerID As Global.System.Int32, contactID As Global.System.Int32, billToAddressID As Global.System.Int32, shipToAddressID As Global.System.Int32, shipMethodID As Global.System.Int32, subTotal As Global.System.Decimal, taxAmt As Global.System.Decimal, freight As Global.System.Decimal, totalDue As Global.System.Decimal, rowguid As Global.System.Guid, modifiedDate As Global.System.DateTime) As SalesOrderHeader
        Dim salesOrderHeader as SalesOrderHeader = New SalesOrderHeader
        salesOrderHeader.SalesOrderID = salesOrderID
        salesOrderHeader.RevisionNumber = revisionNumber
        salesOrderHeader.OrderDate = orderDate
        salesOrderHeader.DueDate = dueDate
        salesOrderHeader.Status = status
        salesOrderHeader.OnlineOrderFlag = onlineOrderFlag
        salesOrderHeader.SalesOrderNumber = salesOrderNumber
        salesOrderHeader.CustomerID = customerID
        salesOrderHeader.ContactID = contactID
        salesOrderHeader.BillToAddressID = billToAddressID
        salesOrderHeader.ShipToAddressID = shipToAddressID
        salesOrderHeader.ShipMethodID = shipMethodID
        salesOrderHeader.SubTotal = subTotal
        salesOrderHeader.TaxAmt = taxAmt
        salesOrderHeader.Freight = freight
        salesOrderHeader.TotalDue = totalDue
        salesOrderHeader.rowguid = rowguid
        salesOrderHeader.ModifiedDate = modifiedDate
        Return salesOrderHeader
    End Function

    #End Region
    #Region "Primitive Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=true, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SalesOrderID() As Global.System.Int32
        Get
            Return _SalesOrderID
        End Get
        Set
            If (_SalesOrderID <> Value) Then
                OnSalesOrderIDChanging(value)
                ReportPropertyChanging("SalesOrderID")
                _SalesOrderID = StructuralObject.SetValidValue(value)
                ReportPropertyChanged("SalesOrderID")
                OnSalesOrderIDChanged()
            End If
        End Set
    End Property

    Private _SalesOrderID As Global.System.Int32
    Private Partial Sub OnSalesOrderIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnSalesOrderIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property RevisionNumber() As Global.System.Byte
        Get
            Return _RevisionNumber
        End Get
        Set
            OnRevisionNumberChanging(value)
            ReportPropertyChanging("RevisionNumber")
            _RevisionNumber = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("RevisionNumber")
            OnRevisionNumberChanged()
        End Set
    End Property

    Private _RevisionNumber As Global.System.Byte
    Private Partial Sub OnRevisionNumberChanging(value As Global.System.Byte)
    End Sub

    Private Partial Sub OnRevisionNumberChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property OrderDate() As Global.System.DateTime
        Get
            Return _OrderDate
        End Get
        Set
            OnOrderDateChanging(value)
            ReportPropertyChanging("OrderDate")
            _OrderDate = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("OrderDate")
            OnOrderDateChanged()
        End Set
    End Property

    Private _OrderDate As Global.System.DateTime
    Private Partial Sub OnOrderDateChanging(value As Global.System.DateTime)
    End Sub

    Private Partial Sub OnOrderDateChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property DueDate() As Global.System.DateTime
        Get
            Return _DueDate
        End Get
        Set
            OnDueDateChanging(value)
            ReportPropertyChanging("DueDate")
            _DueDate = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("DueDate")
            OnDueDateChanged()
        End Set
    End Property

    Private _DueDate As Global.System.DateTime
    Private Partial Sub OnDueDateChanging(value As Global.System.DateTime)
    End Sub

    Private Partial Sub OnDueDateChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property ShipDate() As Nullable(Of Global.System.DateTime)
        Get
            Return _ShipDate
        End Get
        Set
            OnShipDateChanging(value)
            ReportPropertyChanging("ShipDate")
            _ShipDate = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ShipDate")
            OnShipDateChanged()
        End Set
    End Property

    Private _ShipDate As Nullable(Of Global.System.DateTime)
    Private Partial Sub OnShipDateChanging(value As Nullable(Of Global.System.DateTime))
    End Sub

    Private Partial Sub OnShipDateChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property Status() As Global.System.Byte
        Get
            Return _Status
        End Get
        Set
            OnStatusChanging(value)
            ReportPropertyChanging("Status")
            _Status = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("Status")
            OnStatusChanged()
        End Set
    End Property

    Private _Status As Global.System.Byte
    Private Partial Sub OnStatusChanging(value As Global.System.Byte)
    End Sub

    Private Partial Sub OnStatusChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property OnlineOrderFlag() As Global.System.Boolean
        Get
            Return _OnlineOrderFlag
        End Get
        Set
            OnOnlineOrderFlagChanging(value)
            ReportPropertyChanging("OnlineOrderFlag")
            _OnlineOrderFlag = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("OnlineOrderFlag")
            OnOnlineOrderFlagChanged()
        End Set
    End Property

    Private _OnlineOrderFlag As Global.System.Boolean
    Private Partial Sub OnOnlineOrderFlagChanging(value As Global.System.Boolean)
    End Sub

    Private Partial Sub OnOnlineOrderFlagChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SalesOrderNumber() As Global.System.String
        Get
            Return _SalesOrderNumber
        End Get
        Set
            OnSalesOrderNumberChanging(value)
            ReportPropertyChanging("SalesOrderNumber")
            _SalesOrderNumber = StructuralObject.SetValidValue(value, false)
            ReportPropertyChanged("SalesOrderNumber")
            OnSalesOrderNumberChanged()
        End Set
    End Property

    Private _SalesOrderNumber As Global.System.String
    Private Partial Sub OnSalesOrderNumberChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnSalesOrderNumberChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property PurchaseOrderNumber() As Global.System.String
        Get
            Return _PurchaseOrderNumber
        End Get
        Set
            OnPurchaseOrderNumberChanging(value)
            ReportPropertyChanging("PurchaseOrderNumber")
            _PurchaseOrderNumber = StructuralObject.SetValidValue(value, true)
            ReportPropertyChanged("PurchaseOrderNumber")
            OnPurchaseOrderNumberChanged()
        End Set
    End Property

    Private _PurchaseOrderNumber As Global.System.String
    Private Partial Sub OnPurchaseOrderNumberChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnPurchaseOrderNumberChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property AccountNumber() As Global.System.String
        Get
            Return _AccountNumber
        End Get
        Set
            OnAccountNumberChanging(value)
            ReportPropertyChanging("AccountNumber")
            _AccountNumber = StructuralObject.SetValidValue(value, true)
            ReportPropertyChanged("AccountNumber")
            OnAccountNumberChanged()
        End Set
    End Property

    Private _AccountNumber As Global.System.String
    Private Partial Sub OnAccountNumberChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnAccountNumberChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property CustomerID() As Global.System.Int32
        Get
            Return _CustomerID
        End Get
        Set
            OnCustomerIDChanging(value)
            ReportPropertyChanging("CustomerID")
            _CustomerID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("CustomerID")
            OnCustomerIDChanged()
        End Set
    End Property

    Private _CustomerID As Global.System.Int32
    Private Partial Sub OnCustomerIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnCustomerIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ContactID() As Global.System.Int32
        Get
            Return _ContactID
        End Get
        Set
            OnContactIDChanging(value)
            ReportPropertyChanging("ContactID")
            _ContactID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ContactID")
            OnContactIDChanged()
        End Set
    End Property

    Private _ContactID As Global.System.Int32
    Private Partial Sub OnContactIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnContactIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property SalesPersonID() As Nullable(Of Global.System.Int32)
        Get
            Return _SalesPersonID
        End Get
        Set
            OnSalesPersonIDChanging(value)
            ReportPropertyChanging("SalesPersonID")
            _SalesPersonID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("SalesPersonID")
            OnSalesPersonIDChanged()
        End Set
    End Property

    Private _SalesPersonID As Nullable(Of Global.System.Int32)
    Private Partial Sub OnSalesPersonIDChanging(value As Nullable(Of Global.System.Int32))
    End Sub

    Private Partial Sub OnSalesPersonIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property TerritoryID() As Nullable(Of Global.System.Int32)
        Get
            Return _TerritoryID
        End Get
        Set
            OnTerritoryIDChanging(value)
            ReportPropertyChanging("TerritoryID")
            _TerritoryID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("TerritoryID")
            OnTerritoryIDChanged()
        End Set
    End Property

    Private _TerritoryID As Nullable(Of Global.System.Int32)
    Private Partial Sub OnTerritoryIDChanging(value As Nullable(Of Global.System.Int32))
    End Sub

    Private Partial Sub OnTerritoryIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property BillToAddressID() As Global.System.Int32
        Get
            Return _BillToAddressID
        End Get
        Set
            OnBillToAddressIDChanging(value)
            ReportPropertyChanging("BillToAddressID")
            _BillToAddressID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("BillToAddressID")
            OnBillToAddressIDChanged()
        End Set
    End Property

    Private _BillToAddressID As Global.System.Int32
    Private Partial Sub OnBillToAddressIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnBillToAddressIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ShipToAddressID() As Global.System.Int32
        Get
            Return _ShipToAddressID
        End Get
        Set
            OnShipToAddressIDChanging(value)
            ReportPropertyChanging("ShipToAddressID")
            _ShipToAddressID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ShipToAddressID")
            OnShipToAddressIDChanged()
        End Set
    End Property

    Private _ShipToAddressID As Global.System.Int32
    Private Partial Sub OnShipToAddressIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnShipToAddressIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ShipMethodID() As Global.System.Int32
        Get
            Return _ShipMethodID
        End Get
        Set
            OnShipMethodIDChanging(value)
            ReportPropertyChanging("ShipMethodID")
            _ShipMethodID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ShipMethodID")
            OnShipMethodIDChanged()
        End Set
    End Property

    Private _ShipMethodID As Global.System.Int32
    Private Partial Sub OnShipMethodIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnShipMethodIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property CreditCardID() As Nullable(Of Global.System.Int32)
        Get
            Return _CreditCardID
        End Get
        Set
            OnCreditCardIDChanging(value)
            ReportPropertyChanging("CreditCardID")
            _CreditCardID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("CreditCardID")
            OnCreditCardIDChanged()
        End Set
    End Property

    Private _CreditCardID As Nullable(Of Global.System.Int32)
    Private Partial Sub OnCreditCardIDChanging(value As Nullable(Of Global.System.Int32))
    End Sub

    Private Partial Sub OnCreditCardIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property CreditCardApprovalCode() As Global.System.String
        Get
            Return _CreditCardApprovalCode
        End Get
        Set
            OnCreditCardApprovalCodeChanging(value)
            ReportPropertyChanging("CreditCardApprovalCode")
            _CreditCardApprovalCode = StructuralObject.SetValidValue(value, true)
            ReportPropertyChanged("CreditCardApprovalCode")
            OnCreditCardApprovalCodeChanged()
        End Set
    End Property

    Private _CreditCardApprovalCode As Global.System.String
    Private Partial Sub OnCreditCardApprovalCodeChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnCreditCardApprovalCodeChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property CurrencyRateID() As Nullable(Of Global.System.Int32)
        Get
            Return _CurrencyRateID
        End Get
        Set
            OnCurrencyRateIDChanging(value)
            ReportPropertyChanging("CurrencyRateID")
            _CurrencyRateID = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("CurrencyRateID")
            OnCurrencyRateIDChanged()
        End Set
    End Property

    Private _CurrencyRateID As Nullable(Of Global.System.Int32)
    Private Partial Sub OnCurrencyRateIDChanging(value As Nullable(Of Global.System.Int32))
    End Sub

    Private Partial Sub OnCurrencyRateIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SubTotal() As Global.System.Decimal
        Get
            Return _SubTotal
        End Get
        Set
            OnSubTotalChanging(value)
            ReportPropertyChanging("SubTotal")
            _SubTotal = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("SubTotal")
            OnSubTotalChanged()
        End Set
    End Property

    Private _SubTotal As Global.System.Decimal
    Private Partial Sub OnSubTotalChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnSubTotalChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property TaxAmt() As Global.System.Decimal
        Get
            Return _TaxAmt
        End Get
        Set
            OnTaxAmtChanging(value)
            ReportPropertyChanging("TaxAmt")
            _TaxAmt = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("TaxAmt")
            OnTaxAmtChanged()
        End Set
    End Property

    Private _TaxAmt As Global.System.Decimal
    Private Partial Sub OnTaxAmtChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnTaxAmtChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property Freight() As Global.System.Decimal
        Get
            Return _Freight
        End Get
        Set
            OnFreightChanging(value)
            ReportPropertyChanging("Freight")
            _Freight = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("Freight")
            OnFreightChanged()
        End Set
    End Property

    Private _Freight As Global.System.Decimal
    Private Partial Sub OnFreightChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnFreightChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property TotalDue() As Global.System.Decimal
        Get
            Return _TotalDue
        End Get
        Set
            OnTotalDueChanging(value)
            ReportPropertyChanging("TotalDue")
            _TotalDue = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("TotalDue")
            OnTotalDueChanged()
        End Set
    End Property

    Private _TotalDue As Global.System.Decimal
    Private Partial Sub OnTotalDueChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnTotalDueChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=true)>
    <DataMemberAttribute()>
    Public Property Comment() As Global.System.String
        Get
            Return _Comment
        End Get
        Set
            OnCommentChanging(value)
            ReportPropertyChanging("Comment")
            _Comment = StructuralObject.SetValidValue(value, true)
            ReportPropertyChanged("Comment")
            OnCommentChanged()
        End Set
    End Property

    Private _Comment As Global.System.String
    Private Partial Sub OnCommentChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnCommentChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property rowguid() As Global.System.Guid
        Get
            Return _rowguid
        End Get
        Set
            OnrowguidChanging(value)
            ReportPropertyChanging("rowguid")
            _rowguid = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("rowguid")
            OnrowguidChanged()
        End Set
    End Property

    Private _rowguid As Global.System.Guid
    Private Partial Sub OnrowguidChanging(value As Global.System.Guid)
    End Sub

    Private Partial Sub OnrowguidChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ModifiedDate() As Global.System.DateTime
        Get
            Return _ModifiedDate
        End Get
        Set
            OnModifiedDateChanging(value)
            ReportPropertyChanging("ModifiedDate")
            _ModifiedDate = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ModifiedDate")
            OnModifiedDateChanged()
        End Set
    End Property

    Private _ModifiedDate As Global.System.DateTime
    Private Partial Sub OnModifiedDateChanging(value As Global.System.DateTime)
    End Sub

    Private Partial Sub OnModifiedDateChanged()
    End Sub

    #End Region
    #Region "Navigation Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_SalesOrderHeader_Customer_CustomerID", "Customer")>
    Public Property Customer() As Customer
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of Customer)("AdventureWorks_DataModel.FK_SalesOrderHeader_Customer_CustomerID", "Customer").Value
        End Get
        Set
            CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of Customer)("AdventureWorks_DataModel.FK_SalesOrderHeader_Customer_CustomerID", "Customer").Value = value
        End Set
    End Property
    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <BrowsableAttribute(False)>
    <DataMemberAttribute()>
    Public Property CustomerReference() As EntityReference(Of Customer)
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of Customer)("AdventureWorks_DataModel.FK_SalesOrderHeader_Customer_CustomerID", "Customer")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedReference(Of Customer)("AdventureWorks_DataModel.FK_SalesOrderHeader_Customer_CustomerID", "Customer", value)
            End If
        End Set
    End Property

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderDetail")>
     Public Property SalesOrderDetails() As EntityCollection(Of SalesOrderDetail)
        Get
            Return CType(Me,IEntityWithRelationships).RelationshipManager.GetRelatedCollection(Of SalesOrderDetail)("AdventureWorks_DataModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderDetail")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedCollection(Of SalesOrderDetail)("AdventureWorks_DataModel.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderDetail", value)
            End If
        End Set
    End Property

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory")>
    Public Property SalesTerritory() As SalesTerritory
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory").Value
        End Get
        Set
            CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory").Value = value
        End Set
    End Property
    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <BrowsableAttribute(False)>
    <DataMemberAttribute()>
    Public Property SalesTerritoryReference() As EntityReference(Of SalesTerritory)
        Get
            Return CType(Me, IEntityWithRelationships).RelationshipManager.GetRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedReference(Of SalesTerritory)("AdventureWorks_DataModel.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory", value)
            End If
        End Set
    End Property

    #End Region
End Class

''' <summary>
''' No Metadata Documentation available.
''' </summary>
<EdmEntityTypeAttribute(NamespaceName:="AdventureWorks_DataModel", Name:="SalesTerritory")>
<Serializable()>
<DataContractAttribute(IsReference:=True)>
Public Partial Class SalesTerritory
    Inherits EntityObject
    #Region "Factory Method"

    ''' <summary>
    ''' Create a new SalesTerritory object.
    ''' </summary>
    ''' <param name="territoryID">Initial value of the TerritoryID property.</param>
    ''' <param name="name">Initial value of the Name property.</param>
    ''' <param name="countryRegionCode">Initial value of the CountryRegionCode property.</param>
    ''' <param name="group">Initial value of the Group property.</param>
    ''' <param name="salesYTD">Initial value of the SalesYTD property.</param>
    ''' <param name="salesLastYear">Initial value of the SalesLastYear property.</param>
    ''' <param name="costYTD">Initial value of the CostYTD property.</param>
    ''' <param name="costLastYear">Initial value of the CostLastYear property.</param>
    ''' <param name="rowguid">Initial value of the rowguid property.</param>
    ''' <param name="modifiedDate">Initial value of the ModifiedDate property.</param>
    Public Shared Function CreateSalesTerritory(territoryID As Global.System.Int32, name As Global.System.String, countryRegionCode As Global.System.String, group As Global.System.String, salesYTD As Global.System.Decimal, salesLastYear As Global.System.Decimal, costYTD As Global.System.Decimal, costLastYear As Global.System.Decimal, rowguid As Global.System.Guid, modifiedDate As Global.System.DateTime) As SalesTerritory
        Dim salesTerritory as SalesTerritory = New SalesTerritory
        salesTerritory.TerritoryID = territoryID
        salesTerritory.Name = name
        salesTerritory.CountryRegionCode = countryRegionCode
        salesTerritory.Group = group
        salesTerritory.SalesYTD = salesYTD
        salesTerritory.SalesLastYear = salesLastYear
        salesTerritory.CostYTD = costYTD
        salesTerritory.CostLastYear = costLastYear
        salesTerritory.rowguid = rowguid
        salesTerritory.ModifiedDate = modifiedDate
        Return salesTerritory
    End Function

    #End Region
    #Region "Primitive Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=true, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property TerritoryID() As Global.System.Int32
        Get
            Return _TerritoryID
        End Get
        Set
            If (_TerritoryID <> Value) Then
                OnTerritoryIDChanging(value)
                ReportPropertyChanging("TerritoryID")
                _TerritoryID = StructuralObject.SetValidValue(value)
                ReportPropertyChanged("TerritoryID")
                OnTerritoryIDChanged()
            End If
        End Set
    End Property

    Private _TerritoryID As Global.System.Int32
    Private Partial Sub OnTerritoryIDChanging(value As Global.System.Int32)
    End Sub

    Private Partial Sub OnTerritoryIDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property Name() As Global.System.String
        Get
            Return _Name
        End Get
        Set
            OnNameChanging(value)
            ReportPropertyChanging("Name")
            _Name = StructuralObject.SetValidValue(value, false)
            ReportPropertyChanged("Name")
            OnNameChanged()
        End Set
    End Property

    Private _Name As Global.System.String
    Private Partial Sub OnNameChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnNameChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property CountryRegionCode() As Global.System.String
        Get
            Return _CountryRegionCode
        End Get
        Set
            OnCountryRegionCodeChanging(value)
            ReportPropertyChanging("CountryRegionCode")
            _CountryRegionCode = StructuralObject.SetValidValue(value, false)
            ReportPropertyChanged("CountryRegionCode")
            OnCountryRegionCodeChanged()
        End Set
    End Property

    Private _CountryRegionCode As Global.System.String
    Private Partial Sub OnCountryRegionCodeChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnCountryRegionCodeChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property Group() As Global.System.String
        Get
            Return _Group
        End Get
        Set
            OnGroupChanging(value)
            ReportPropertyChanging("Group")
            _Group = StructuralObject.SetValidValue(value, false)
            ReportPropertyChanged("Group")
            OnGroupChanged()
        End Set
    End Property

    Private _Group As Global.System.String
    Private Partial Sub OnGroupChanging(value As Global.System.String)
    End Sub

    Private Partial Sub OnGroupChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SalesYTD() As Global.System.Decimal
        Get
            Return _SalesYTD
        End Get
        Set
            OnSalesYTDChanging(value)
            ReportPropertyChanging("SalesYTD")
            _SalesYTD = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("SalesYTD")
            OnSalesYTDChanged()
        End Set
    End Property

    Private _SalesYTD As Global.System.Decimal
    Private Partial Sub OnSalesYTDChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnSalesYTDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property SalesLastYear() As Global.System.Decimal
        Get
            Return _SalesLastYear
        End Get
        Set
            OnSalesLastYearChanging(value)
            ReportPropertyChanging("SalesLastYear")
            _SalesLastYear = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("SalesLastYear")
            OnSalesLastYearChanged()
        End Set
    End Property

    Private _SalesLastYear As Global.System.Decimal
    Private Partial Sub OnSalesLastYearChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnSalesLastYearChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property CostYTD() As Global.System.Decimal
        Get
            Return _CostYTD
        End Get
        Set
            OnCostYTDChanging(value)
            ReportPropertyChanging("CostYTD")
            _CostYTD = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("CostYTD")
            OnCostYTDChanged()
        End Set
    End Property

    Private _CostYTD As Global.System.Decimal
    Private Partial Sub OnCostYTDChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnCostYTDChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property CostLastYear() As Global.System.Decimal
        Get
            Return _CostLastYear
        End Get
        Set
            OnCostLastYearChanging(value)
            ReportPropertyChanging("CostLastYear")
            _CostLastYear = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("CostLastYear")
            OnCostLastYearChanged()
        End Set
    End Property

    Private _CostLastYear As Global.System.Decimal
    Private Partial Sub OnCostLastYearChanging(value As Global.System.Decimal)
    End Sub

    Private Partial Sub OnCostLastYearChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property rowguid() As Global.System.Guid
        Get
            Return _rowguid
        End Get
        Set
            OnrowguidChanging(value)
            ReportPropertyChanging("rowguid")
            _rowguid = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("rowguid")
            OnrowguidChanged()
        End Set
    End Property

    Private _rowguid As Global.System.Guid
    Private Partial Sub OnrowguidChanging(value As Global.System.Guid)
    End Sub

    Private Partial Sub OnrowguidChanged()
    End Sub

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <EdmScalarPropertyAttribute(EntityKeyProperty:=false, IsNullable:=false)>
    <DataMemberAttribute()>
    Public Property ModifiedDate() As Global.System.DateTime
        Get
            Return _ModifiedDate
        End Get
        Set
            OnModifiedDateChanging(value)
            ReportPropertyChanging("ModifiedDate")
            _ModifiedDate = StructuralObject.SetValidValue(value)
            ReportPropertyChanged("ModifiedDate")
            OnModifiedDateChanged()
        End Set
    End Property

    Private _ModifiedDate As Global.System.DateTime
    Private Partial Sub OnModifiedDateChanging(value As Global.System.DateTime)
    End Sub

    Private Partial Sub OnModifiedDateChanged()
    End Sub

    #End Region
    #Region "Navigation Properties"

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_Customer_SalesTerritory_TerritoryID", "Customer")>
     Public Property Customers() As EntityCollection(Of Customer)
        Get
            Return CType(Me,IEntityWithRelationships).RelationshipManager.GetRelatedCollection(Of Customer)("AdventureWorks_DataModel.FK_Customer_SalesTerritory_TerritoryID", "Customer")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedCollection(Of Customer)("AdventureWorks_DataModel.FK_Customer_SalesTerritory_TerritoryID", "Customer", value)
            End If
        End Set
    End Property

    ''' <summary>
    ''' No Metadata Documentation available.
    ''' </summary>
    <XmlIgnoreAttribute()>
    <SoapIgnoreAttribute()>
    <DataMemberAttribute()>
    <EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel", "FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesOrderHeader")>
     Public Property SalesOrderHeaders() As EntityCollection(Of SalesOrderHeader)
        Get
            Return CType(Me,IEntityWithRelationships).RelationshipManager.GetRelatedCollection(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesOrderHeader")
        End Get
        Set
            If (Not value Is Nothing)
                CType(Me, IEntityWithRelationships).RelationshipManager.InitializeRelatedCollection(Of SalesOrderHeader)("AdventureWorks_DataModel.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesOrderHeader", value)
            End If
        End Set
    End Property

    #End Region
End Class

#End Region

