//------------------------------------------------------------------------------
// <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>
//------------------------------------------------------------------------------

using System;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Data.EntityClient;
using System.ComponentModel;
using System.Xml.Serialization;
using System.Runtime.Serialization;

[assembly: EdmSchemaAttribute()]
#region EDM Relationship Metadata

[assembly: EdmRelationshipAttribute("AdventureWorks_DataModel1", "FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory", System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(AspnetEntityFx.SalesTerritory), "Customer", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(AspnetEntityFx.Customer), true)]
[assembly: EdmRelationshipAttribute("AdventureWorks_DataModel1", "FK_SalesOrderHeader_Customer_CustomerID", "Customer", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(AspnetEntityFx.Customer), "SalesOrderHeader", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(AspnetEntityFx.SalesOrderHeader), true)]
[assembly: EdmRelationshipAttribute("AdventureWorks_DataModel1", "FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader", System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(AspnetEntityFx.SalesOrderHeader), "SalesOrderDetail", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(AspnetEntityFx.SalesOrderDetail), true)]
[assembly: EdmRelationshipAttribute("AdventureWorks_DataModel1", "FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory", System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(AspnetEntityFx.SalesTerritory), "SalesOrderHeader", System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(AspnetEntityFx.SalesOrderHeader), true)]

#endregion

namespace AspnetEntityFx
{
    #region Contexts
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    public partial class AdventureWorks_DataEntities1 : ObjectContext
    {
        #region Constructors
    
        /// <summary>
        /// Initializes a new AdventureWorks_DataEntities1 object using the connection string found in the 'AdventureWorks_DataEntities1' section of the application configuration file.
        /// </summary>
        public AdventureWorks_DataEntities1() : base("name=AdventureWorks_DataEntities1", "AdventureWorks_DataEntities1")
        {
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new AdventureWorks_DataEntities1 object.
        /// </summary>
        public AdventureWorks_DataEntities1(string connectionString) : base(connectionString, "AdventureWorks_DataEntities1")
        {
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new AdventureWorks_DataEntities1 object.
        /// </summary>
        public AdventureWorks_DataEntities1(EntityConnection connection) : base(connection, "AdventureWorks_DataEntities1")
        {
            OnContextCreated();
        }
    
        #endregion
    
        #region Partial Methods
    
        partial void OnContextCreated();
    
        #endregion
    
        #region ObjectSet Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Customer> Customers
        {
            get
            {
                if ((_Customers == null))
                {
                    _Customers = base.CreateObjectSet<Customer>("Customers");
                }
                return _Customers;
            }
        }
        private ObjectSet<Customer> _Customers;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<SalesOrderDetail> SalesOrderDetails
        {
            get
            {
                if ((_SalesOrderDetails == null))
                {
                    _SalesOrderDetails = base.CreateObjectSet<SalesOrderDetail>("SalesOrderDetails");
                }
                return _SalesOrderDetails;
            }
        }
        private ObjectSet<SalesOrderDetail> _SalesOrderDetails;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<SalesOrderHeader> SalesOrderHeaders
        {
            get
            {
                if ((_SalesOrderHeaders == null))
                {
                    _SalesOrderHeaders = base.CreateObjectSet<SalesOrderHeader>("SalesOrderHeaders");
                }
                return _SalesOrderHeaders;
            }
        }
        private ObjectSet<SalesOrderHeader> _SalesOrderHeaders;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<SalesTerritory> SalesTerritories
        {
            get
            {
                if ((_SalesTerritories == null))
                {
                    _SalesTerritories = base.CreateObjectSet<SalesTerritory>("SalesTerritories");
                }
                return _SalesTerritories;
            }
        }
        private ObjectSet<SalesTerritory> _SalesTerritories;

        #endregion
        #region AddTo Methods
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToCustomers(Customer customer)
        {
            base.AddObject("Customers", customer);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the SalesOrderDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToSalesOrderDetails(SalesOrderDetail salesOrderDetail)
        {
            base.AddObject("SalesOrderDetails", salesOrderDetail);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the SalesOrderHeaders EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToSalesOrderHeaders(SalesOrderHeader salesOrderHeader)
        {
            base.AddObject("SalesOrderHeaders", salesOrderHeader);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the SalesTerritories EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToSalesTerritories(SalesTerritory salesTerritory)
        {
            base.AddObject("SalesTerritories", salesTerritory);
        }

        #endregion
    }
    

    #endregion
    
    #region Entities
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="AdventureWorks_DataModel1", Name="Customer")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    [KnownTypeAttribute(typeof(IndividualCustomer))]
    public partial class Customer : 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 static Customer CreateCustomer(global::System.Int32 customerID, global::System.String accountNumber, global::System.Guid rowguid, global::System.DateTime modifiedDate)
        {
            Customer customer = new Customer();
            customer.CustomerID = customerID;
            customer.AccountNumber = accountNumber;
            customer.rowguid = rowguid;
            customer.ModifiedDate = modifiedDate;
            return customer;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 CustomerID
        {
            get
            {
                return _CustomerID;
            }
            set
            {
                if (_CustomerID != value)
                {
                    OnCustomerIDChanging(value);
                    ReportPropertyChanging("CustomerID");
                    _CustomerID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("CustomerID");
                    OnCustomerIDChanged();
                }
            }
        }
        private global::System.Int32 _CustomerID;
        partial void OnCustomerIDChanging(global::System.Int32 value);
        partial void OnCustomerIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> TerritoryID
        {
            get
            {
                return _TerritoryID;
            }
            set
            {
                OnTerritoryIDChanging(value);
                ReportPropertyChanging("TerritoryID");
                _TerritoryID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("TerritoryID");
                OnTerritoryIDChanged();
            }
        }
        private Nullable<global::System.Int32> _TerritoryID;
        partial void OnTerritoryIDChanging(Nullable<global::System.Int32> value);
        partial void OnTerritoryIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String AccountNumber
        {
            get
            {
                return _AccountNumber;
            }
            set
            {
                OnAccountNumberChanging(value);
                ReportPropertyChanging("AccountNumber");
                _AccountNumber = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("AccountNumber");
                OnAccountNumberChanged();
            }
        }
        private global::System.String _AccountNumber;
        partial void OnAccountNumberChanging(global::System.String value);
        partial void OnAccountNumberChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Guid rowguid
        {
            get
            {
                return _rowguid;
            }
            set
            {
                OnrowguidChanging(value);
                ReportPropertyChanging("rowguid");
                _rowguid = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("rowguid");
                OnrowguidChanged();
            }
        }
        private global::System.Guid _rowguid;
        partial void OnrowguidChanging(global::System.Guid value);
        partial void OnrowguidChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime ModifiedDate
        {
            get
            {
                return _ModifiedDate;
            }
            set
            {
                OnModifiedDateChanging(value);
                ReportPropertyChanging("ModifiedDate");
                _ModifiedDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ModifiedDate");
                OnModifiedDateChanged();
            }
        }
        private global::System.DateTime _ModifiedDate;
        partial void OnModifiedDateChanging(global::System.DateTime value);
        partial void OnModifiedDateChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory")]
        public SalesTerritory SalesTerritory
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<SalesTerritory> SalesTerritoryReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_Customer_SalesTerritory_TerritoryID", "SalesTerritory", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_SalesOrderHeader_Customer_CustomerID", "SalesOrderHeader")]
        public EntityCollection<SalesOrderHeader> SalesOrderHeaders
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderHeader_Customer_CustomerID", "SalesOrderHeader");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderHeader_Customer_CustomerID", "SalesOrderHeader", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="AdventureWorks_DataModel1", Name="IndividualCustomer")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class IndividualCustomer : 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 static IndividualCustomer CreateIndividualCustomer(global::System.Int32 customerID, global::System.String accountNumber, global::System.Guid rowguid, global::System.DateTime modifiedDate)
        {
            IndividualCustomer individualCustomer = new IndividualCustomer();
            individualCustomer.CustomerID = customerID;
            individualCustomer.AccountNumber = accountNumber;
            individualCustomer.rowguid = rowguid;
            individualCustomer.ModifiedDate = modifiedDate;
            return individualCustomer;
        }

        #endregion
    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="AdventureWorks_DataModel1", Name="SalesOrderDetail")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class SalesOrderDetail : 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 static SalesOrderDetail CreateSalesOrderDetail(global::System.Int32 salesOrderID, global::System.Int32 salesOrderDetailID, global::System.Int16 orderQty, global::System.Int32 productID, global::System.Int32 specialOfferID, global::System.Decimal unitPrice, global::System.Decimal unitPriceDiscount, global::System.Decimal lineTotal, global::System.Guid rowguid, global::System.DateTime modifiedDate)
        {
            SalesOrderDetail 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;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 SalesOrderID
        {
            get
            {
                return _SalesOrderID;
            }
            set
            {
                if (_SalesOrderID != value)
                {
                    OnSalesOrderIDChanging(value);
                    ReportPropertyChanging("SalesOrderID");
                    _SalesOrderID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("SalesOrderID");
                    OnSalesOrderIDChanged();
                }
            }
        }
        private global::System.Int32 _SalesOrderID;
        partial void OnSalesOrderIDChanging(global::System.Int32 value);
        partial void OnSalesOrderIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 SalesOrderDetailID
        {
            get
            {
                return _SalesOrderDetailID;
            }
            set
            {
                if (_SalesOrderDetailID != value)
                {
                    OnSalesOrderDetailIDChanging(value);
                    ReportPropertyChanging("SalesOrderDetailID");
                    _SalesOrderDetailID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("SalesOrderDetailID");
                    OnSalesOrderDetailIDChanged();
                }
            }
        }
        private global::System.Int32 _SalesOrderDetailID;
        partial void OnSalesOrderDetailIDChanging(global::System.Int32 value);
        partial void OnSalesOrderDetailIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String CarrierTrackingNumber
        {
            get
            {
                return _CarrierTrackingNumber;
            }
            set
            {
                OnCarrierTrackingNumberChanging(value);
                ReportPropertyChanging("CarrierTrackingNumber");
                _CarrierTrackingNumber = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("CarrierTrackingNumber");
                OnCarrierTrackingNumberChanged();
            }
        }
        private global::System.String _CarrierTrackingNumber;
        partial void OnCarrierTrackingNumberChanging(global::System.String value);
        partial void OnCarrierTrackingNumberChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int16 OrderQty
        {
            get
            {
                return _OrderQty;
            }
            set
            {
                OnOrderQtyChanging(value);
                ReportPropertyChanging("OrderQty");
                _OrderQty = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("OrderQty");
                OnOrderQtyChanged();
            }
        }
        private global::System.Int16 _OrderQty;
        partial void OnOrderQtyChanging(global::System.Int16 value);
        partial void OnOrderQtyChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ProductID
        {
            get
            {
                return _ProductID;
            }
            set
            {
                OnProductIDChanging(value);
                ReportPropertyChanging("ProductID");
                _ProductID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ProductID");
                OnProductIDChanged();
            }
        }
        private global::System.Int32 _ProductID;
        partial void OnProductIDChanging(global::System.Int32 value);
        partial void OnProductIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 SpecialOfferID
        {
            get
            {
                return _SpecialOfferID;
            }
            set
            {
                OnSpecialOfferIDChanging(value);
                ReportPropertyChanging("SpecialOfferID");
                _SpecialOfferID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("SpecialOfferID");
                OnSpecialOfferIDChanged();
            }
        }
        private global::System.Int32 _SpecialOfferID;
        partial void OnSpecialOfferIDChanging(global::System.Int32 value);
        partial void OnSpecialOfferIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal UnitPrice
        {
            get
            {
                return _UnitPrice;
            }
            set
            {
                OnUnitPriceChanging(value);
                ReportPropertyChanging("UnitPrice");
                _UnitPrice = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("UnitPrice");
                OnUnitPriceChanged();
            }
        }
        private global::System.Decimal _UnitPrice;
        partial void OnUnitPriceChanging(global::System.Decimal value);
        partial void OnUnitPriceChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal UnitPriceDiscount
        {
            get
            {
                return _UnitPriceDiscount;
            }
            set
            {
                OnUnitPriceDiscountChanging(value);
                ReportPropertyChanging("UnitPriceDiscount");
                _UnitPriceDiscount = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("UnitPriceDiscount");
                OnUnitPriceDiscountChanged();
            }
        }
        private global::System.Decimal _UnitPriceDiscount;
        partial void OnUnitPriceDiscountChanging(global::System.Decimal value);
        partial void OnUnitPriceDiscountChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal LineTotal
        {
            get
            {
                return _LineTotal;
            }
            set
            {
                OnLineTotalChanging(value);
                ReportPropertyChanging("LineTotal");
                _LineTotal = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("LineTotal");
                OnLineTotalChanged();
            }
        }
        private global::System.Decimal _LineTotal;
        partial void OnLineTotalChanging(global::System.Decimal value);
        partial void OnLineTotalChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Guid rowguid
        {
            get
            {
                return _rowguid;
            }
            set
            {
                OnrowguidChanging(value);
                ReportPropertyChanging("rowguid");
                _rowguid = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("rowguid");
                OnrowguidChanged();
            }
        }
        private global::System.Guid _rowguid;
        partial void OnrowguidChanging(global::System.Guid value);
        partial void OnrowguidChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime ModifiedDate
        {
            get
            {
                return _ModifiedDate;
            }
            set
            {
                OnModifiedDateChanging(value);
                ReportPropertyChanging("ModifiedDate");
                _ModifiedDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ModifiedDate");
                OnModifiedDateChanged();
            }
        }
        private global::System.DateTime _ModifiedDate;
        partial void OnModifiedDateChanging(global::System.DateTime value);
        partial void OnModifiedDateChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader")]
        public SalesOrderHeader SalesOrderHeader
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<SalesOrderHeader> SalesOrderHeaderReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderHeader", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="AdventureWorks_DataModel1", Name="SalesOrderHeader")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class SalesOrderHeader : 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 static SalesOrderHeader CreateSalesOrderHeader(global::System.Int32 salesOrderID, global::System.Byte revisionNumber, global::System.DateTime orderDate, global::System.DateTime dueDate, global::System.Byte status, global::System.Boolean onlineOrderFlag, global::System.String salesOrderNumber, global::System.Int32 customerID, global::System.Int32 contactID, global::System.Int32 billToAddressID, global::System.Int32 shipToAddressID, global::System.Int32 shipMethodID, global::System.Decimal subTotal, global::System.Decimal taxAmt, global::System.Decimal freight, global::System.Decimal totalDue, global::System.Guid rowguid, global::System.DateTime modifiedDate)
        {
            SalesOrderHeader 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;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 SalesOrderID
        {
            get
            {
                return _SalesOrderID;
            }
            set
            {
                if (_SalesOrderID != value)
                {
                    OnSalesOrderIDChanging(value);
                    ReportPropertyChanging("SalesOrderID");
                    _SalesOrderID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("SalesOrderID");
                    OnSalesOrderIDChanged();
                }
            }
        }
        private global::System.Int32 _SalesOrderID;
        partial void OnSalesOrderIDChanging(global::System.Int32 value);
        partial void OnSalesOrderIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Byte RevisionNumber
        {
            get
            {
                return _RevisionNumber;
            }
            set
            {
                OnRevisionNumberChanging(value);
                ReportPropertyChanging("RevisionNumber");
                _RevisionNumber = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("RevisionNumber");
                OnRevisionNumberChanged();
            }
        }
        private global::System.Byte _RevisionNumber;
        partial void OnRevisionNumberChanging(global::System.Byte value);
        partial void OnRevisionNumberChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime OrderDate
        {
            get
            {
                return _OrderDate;
            }
            set
            {
                OnOrderDateChanging(value);
                ReportPropertyChanging("OrderDate");
                _OrderDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("OrderDate");
                OnOrderDateChanged();
            }
        }
        private global::System.DateTime _OrderDate;
        partial void OnOrderDateChanging(global::System.DateTime value);
        partial void OnOrderDateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime DueDate
        {
            get
            {
                return _DueDate;
            }
            set
            {
                OnDueDateChanging(value);
                ReportPropertyChanging("DueDate");
                _DueDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("DueDate");
                OnDueDateChanged();
            }
        }
        private global::System.DateTime _DueDate;
        partial void OnDueDateChanging(global::System.DateTime value);
        partial void OnDueDateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.DateTime> ShipDate
        {
            get
            {
                return _ShipDate;
            }
            set
            {
                OnShipDateChanging(value);
                ReportPropertyChanging("ShipDate");
                _ShipDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ShipDate");
                OnShipDateChanged();
            }
        }
        private Nullable<global::System.DateTime> _ShipDate;
        partial void OnShipDateChanging(Nullable<global::System.DateTime> value);
        partial void OnShipDateChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Byte Status
        {
            get
            {
                return _Status;
            }
            set
            {
                OnStatusChanging(value);
                ReportPropertyChanging("Status");
                _Status = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Status");
                OnStatusChanged();
            }
        }
        private global::System.Byte _Status;
        partial void OnStatusChanging(global::System.Byte value);
        partial void OnStatusChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Boolean OnlineOrderFlag
        {
            get
            {
                return _OnlineOrderFlag;
            }
            set
            {
                OnOnlineOrderFlagChanging(value);
                ReportPropertyChanging("OnlineOrderFlag");
                _OnlineOrderFlag = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("OnlineOrderFlag");
                OnOnlineOrderFlagChanged();
            }
        }
        private global::System.Boolean _OnlineOrderFlag;
        partial void OnOnlineOrderFlagChanging(global::System.Boolean value);
        partial void OnOnlineOrderFlagChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String SalesOrderNumber
        {
            get
            {
                return _SalesOrderNumber;
            }
            set
            {
                OnSalesOrderNumberChanging(value);
                ReportPropertyChanging("SalesOrderNumber");
                _SalesOrderNumber = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("SalesOrderNumber");
                OnSalesOrderNumberChanged();
            }
        }
        private global::System.String _SalesOrderNumber;
        partial void OnSalesOrderNumberChanging(global::System.String value);
        partial void OnSalesOrderNumberChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String PurchaseOrderNumber
        {
            get
            {
                return _PurchaseOrderNumber;
            }
            set
            {
                OnPurchaseOrderNumberChanging(value);
                ReportPropertyChanging("PurchaseOrderNumber");
                _PurchaseOrderNumber = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("PurchaseOrderNumber");
                OnPurchaseOrderNumberChanged();
            }
        }
        private global::System.String _PurchaseOrderNumber;
        partial void OnPurchaseOrderNumberChanging(global::System.String value);
        partial void OnPurchaseOrderNumberChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String AccountNumber
        {
            get
            {
                return _AccountNumber;
            }
            set
            {
                OnAccountNumberChanging(value);
                ReportPropertyChanging("AccountNumber");
                _AccountNumber = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("AccountNumber");
                OnAccountNumberChanged();
            }
        }
        private global::System.String _AccountNumber;
        partial void OnAccountNumberChanging(global::System.String value);
        partial void OnAccountNumberChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 CustomerID
        {
            get
            {
                return _CustomerID;
            }
            set
            {
                OnCustomerIDChanging(value);
                ReportPropertyChanging("CustomerID");
                _CustomerID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("CustomerID");
                OnCustomerIDChanged();
            }
        }
        private global::System.Int32 _CustomerID;
        partial void OnCustomerIDChanging(global::System.Int32 value);
        partial void OnCustomerIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ContactID
        {
            get
            {
                return _ContactID;
            }
            set
            {
                OnContactIDChanging(value);
                ReportPropertyChanging("ContactID");
                _ContactID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ContactID");
                OnContactIDChanged();
            }
        }
        private global::System.Int32 _ContactID;
        partial void OnContactIDChanging(global::System.Int32 value);
        partial void OnContactIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> SalesPersonID
        {
            get
            {
                return _SalesPersonID;
            }
            set
            {
                OnSalesPersonIDChanging(value);
                ReportPropertyChanging("SalesPersonID");
                _SalesPersonID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("SalesPersonID");
                OnSalesPersonIDChanged();
            }
        }
        private Nullable<global::System.Int32> _SalesPersonID;
        partial void OnSalesPersonIDChanging(Nullable<global::System.Int32> value);
        partial void OnSalesPersonIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> TerritoryID
        {
            get
            {
                return _TerritoryID;
            }
            set
            {
                OnTerritoryIDChanging(value);
                ReportPropertyChanging("TerritoryID");
                _TerritoryID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("TerritoryID");
                OnTerritoryIDChanged();
            }
        }
        private Nullable<global::System.Int32> _TerritoryID;
        partial void OnTerritoryIDChanging(Nullable<global::System.Int32> value);
        partial void OnTerritoryIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 BillToAddressID
        {
            get
            {
                return _BillToAddressID;
            }
            set
            {
                OnBillToAddressIDChanging(value);
                ReportPropertyChanging("BillToAddressID");
                _BillToAddressID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("BillToAddressID");
                OnBillToAddressIDChanged();
            }
        }
        private global::System.Int32 _BillToAddressID;
        partial void OnBillToAddressIDChanging(global::System.Int32 value);
        partial void OnBillToAddressIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ShipToAddressID
        {
            get
            {
                return _ShipToAddressID;
            }
            set
            {
                OnShipToAddressIDChanging(value);
                ReportPropertyChanging("ShipToAddressID");
                _ShipToAddressID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ShipToAddressID");
                OnShipToAddressIDChanged();
            }
        }
        private global::System.Int32 _ShipToAddressID;
        partial void OnShipToAddressIDChanging(global::System.Int32 value);
        partial void OnShipToAddressIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 ShipMethodID
        {
            get
            {
                return _ShipMethodID;
            }
            set
            {
                OnShipMethodIDChanging(value);
                ReportPropertyChanging("ShipMethodID");
                _ShipMethodID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ShipMethodID");
                OnShipMethodIDChanged();
            }
        }
        private global::System.Int32 _ShipMethodID;
        partial void OnShipMethodIDChanging(global::System.Int32 value);
        partial void OnShipMethodIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> CreditCardID
        {
            get
            {
                return _CreditCardID;
            }
            set
            {
                OnCreditCardIDChanging(value);
                ReportPropertyChanging("CreditCardID");
                _CreditCardID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("CreditCardID");
                OnCreditCardIDChanged();
            }
        }
        private Nullable<global::System.Int32> _CreditCardID;
        partial void OnCreditCardIDChanging(Nullable<global::System.Int32> value);
        partial void OnCreditCardIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String CreditCardApprovalCode
        {
            get
            {
                return _CreditCardApprovalCode;
            }
            set
            {
                OnCreditCardApprovalCodeChanging(value);
                ReportPropertyChanging("CreditCardApprovalCode");
                _CreditCardApprovalCode = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("CreditCardApprovalCode");
                OnCreditCardApprovalCodeChanged();
            }
        }
        private global::System.String _CreditCardApprovalCode;
        partial void OnCreditCardApprovalCodeChanging(global::System.String value);
        partial void OnCreditCardApprovalCodeChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> CurrencyRateID
        {
            get
            {
                return _CurrencyRateID;
            }
            set
            {
                OnCurrencyRateIDChanging(value);
                ReportPropertyChanging("CurrencyRateID");
                _CurrencyRateID = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("CurrencyRateID");
                OnCurrencyRateIDChanged();
            }
        }
        private Nullable<global::System.Int32> _CurrencyRateID;
        partial void OnCurrencyRateIDChanging(Nullable<global::System.Int32> value);
        partial void OnCurrencyRateIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal SubTotal
        {
            get
            {
                return _SubTotal;
            }
            set
            {
                OnSubTotalChanging(value);
                ReportPropertyChanging("SubTotal");
                _SubTotal = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("SubTotal");
                OnSubTotalChanged();
            }
        }
        private global::System.Decimal _SubTotal;
        partial void OnSubTotalChanging(global::System.Decimal value);
        partial void OnSubTotalChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal TaxAmt
        {
            get
            {
                return _TaxAmt;
            }
            set
            {
                OnTaxAmtChanging(value);
                ReportPropertyChanging("TaxAmt");
                _TaxAmt = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("TaxAmt");
                OnTaxAmtChanged();
            }
        }
        private global::System.Decimal _TaxAmt;
        partial void OnTaxAmtChanging(global::System.Decimal value);
        partial void OnTaxAmtChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal Freight
        {
            get
            {
                return _Freight;
            }
            set
            {
                OnFreightChanging(value);
                ReportPropertyChanging("Freight");
                _Freight = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Freight");
                OnFreightChanged();
            }
        }
        private global::System.Decimal _Freight;
        partial void OnFreightChanging(global::System.Decimal value);
        partial void OnFreightChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal TotalDue
        {
            get
            {
                return _TotalDue;
            }
            set
            {
                OnTotalDueChanging(value);
                ReportPropertyChanging("TotalDue");
                _TotalDue = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("TotalDue");
                OnTotalDueChanged();
            }
        }
        private global::System.Decimal _TotalDue;
        partial void OnTotalDueChanging(global::System.Decimal value);
        partial void OnTotalDueChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Comment
        {
            get
            {
                return _Comment;
            }
            set
            {
                OnCommentChanging(value);
                ReportPropertyChanging("Comment");
                _Comment = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Comment");
                OnCommentChanged();
            }
        }
        private global::System.String _Comment;
        partial void OnCommentChanging(global::System.String value);
        partial void OnCommentChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Guid rowguid
        {
            get
            {
                return _rowguid;
            }
            set
            {
                OnrowguidChanging(value);
                ReportPropertyChanging("rowguid");
                _rowguid = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("rowguid");
                OnrowguidChanged();
            }
        }
        private global::System.Guid _rowguid;
        partial void OnrowguidChanging(global::System.Guid value);
        partial void OnrowguidChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime ModifiedDate
        {
            get
            {
                return _ModifiedDate;
            }
            set
            {
                OnModifiedDateChanging(value);
                ReportPropertyChanging("ModifiedDate");
                _ModifiedDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ModifiedDate");
                OnModifiedDateChanged();
            }
        }
        private global::System.DateTime _ModifiedDate;
        partial void OnModifiedDateChanging(global::System.DateTime value);
        partial void OnModifiedDateChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_SalesOrderHeader_Customer_CustomerID", "Customer")]
        public Customer Customer
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Customer>("AdventureWorks_DataModel1.FK_SalesOrderHeader_Customer_CustomerID", "Customer").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Customer>("AdventureWorks_DataModel1.FK_SalesOrderHeader_Customer_CustomerID", "Customer").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<Customer> CustomerReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<Customer>("AdventureWorks_DataModel1.FK_SalesOrderHeader_Customer_CustomerID", "Customer");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<Customer>("AdventureWorks_DataModel1.FK_SalesOrderHeader_Customer_CustomerID", "Customer", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderDetail")]
        public EntityCollection<SalesOrderDetail> SalesOrderDetails
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<SalesOrderDetail>("AdventureWorks_DataModel1.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderDetail");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<SalesOrderDetail>("AdventureWorks_DataModel1.FK_SalesOrderDetail_SalesOrderHeader_SalesOrderID", "SalesOrderDetail", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory")]
        public SalesTerritory SalesTerritory
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory").Value;
            }
            set
            {
                ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory").Value = value;
            }
        }
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [BrowsableAttribute(false)]
        [DataMemberAttribute()]
        public EntityReference<SalesTerritory> SalesTerritoryReference
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedReference<SalesTerritory>("AdventureWorks_DataModel1.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesTerritory", value);
                }
            }
        }

        #endregion
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="AdventureWorks_DataModel1", Name="SalesTerritory")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class SalesTerritory : 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 static SalesTerritory CreateSalesTerritory(global::System.Int32 territoryID, global::System.String name, global::System.String countryRegionCode, global::System.String group, global::System.Decimal salesYTD, global::System.Decimal salesLastYear, global::System.Decimal costYTD, global::System.Decimal costLastYear, global::System.Guid rowguid, global::System.DateTime modifiedDate)
        {
            SalesTerritory 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;
        }

        #endregion
        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 TerritoryID
        {
            get
            {
                return _TerritoryID;
            }
            set
            {
                if (_TerritoryID != value)
                {
                    OnTerritoryIDChanging(value);
                    ReportPropertyChanging("TerritoryID");
                    _TerritoryID = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("TerritoryID");
                    OnTerritoryIDChanged();
                }
            }
        }
        private global::System.Int32 _TerritoryID;
        partial void OnTerritoryIDChanging(global::System.Int32 value);
        partial void OnTerritoryIDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String Name
        {
            get
            {
                return _Name;
            }
            set
            {
                OnNameChanging(value);
                ReportPropertyChanging("Name");
                _Name = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("Name");
                OnNameChanged();
            }
        }
        private global::System.String _Name;
        partial void OnNameChanging(global::System.String value);
        partial void OnNameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String CountryRegionCode
        {
            get
            {
                return _CountryRegionCode;
            }
            set
            {
                OnCountryRegionCodeChanging(value);
                ReportPropertyChanging("CountryRegionCode");
                _CountryRegionCode = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("CountryRegionCode");
                OnCountryRegionCodeChanged();
            }
        }
        private global::System.String _CountryRegionCode;
        partial void OnCountryRegionCodeChanging(global::System.String value);
        partial void OnCountryRegionCodeChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.String Group
        {
            get
            {
                return _Group;
            }
            set
            {
                OnGroupChanging(value);
                ReportPropertyChanging("Group");
                _Group = StructuralObject.SetValidValue(value, false);
                ReportPropertyChanged("Group");
                OnGroupChanged();
            }
        }
        private global::System.String _Group;
        partial void OnGroupChanging(global::System.String value);
        partial void OnGroupChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal SalesYTD
        {
            get
            {
                return _SalesYTD;
            }
            set
            {
                OnSalesYTDChanging(value);
                ReportPropertyChanging("SalesYTD");
                _SalesYTD = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("SalesYTD");
                OnSalesYTDChanged();
            }
        }
        private global::System.Decimal _SalesYTD;
        partial void OnSalesYTDChanging(global::System.Decimal value);
        partial void OnSalesYTDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal SalesLastYear
        {
            get
            {
                return _SalesLastYear;
            }
            set
            {
                OnSalesLastYearChanging(value);
                ReportPropertyChanging("SalesLastYear");
                _SalesLastYear = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("SalesLastYear");
                OnSalesLastYearChanged();
            }
        }
        private global::System.Decimal _SalesLastYear;
        partial void OnSalesLastYearChanging(global::System.Decimal value);
        partial void OnSalesLastYearChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal CostYTD
        {
            get
            {
                return _CostYTD;
            }
            set
            {
                OnCostYTDChanging(value);
                ReportPropertyChanging("CostYTD");
                _CostYTD = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("CostYTD");
                OnCostYTDChanged();
            }
        }
        private global::System.Decimal _CostYTD;
        partial void OnCostYTDChanging(global::System.Decimal value);
        partial void OnCostYTDChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Decimal CostLastYear
        {
            get
            {
                return _CostLastYear;
            }
            set
            {
                OnCostLastYearChanging(value);
                ReportPropertyChanging("CostLastYear");
                _CostLastYear = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("CostLastYear");
                OnCostLastYearChanged();
            }
        }
        private global::System.Decimal _CostLastYear;
        partial void OnCostLastYearChanging(global::System.Decimal value);
        partial void OnCostLastYearChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Guid rowguid
        {
            get
            {
                return _rowguid;
            }
            set
            {
                OnrowguidChanging(value);
                ReportPropertyChanging("rowguid");
                _rowguid = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("rowguid");
                OnrowguidChanged();
            }
        }
        private global::System.Guid _rowguid;
        partial void OnrowguidChanging(global::System.Guid value);
        partial void OnrowguidChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.DateTime ModifiedDate
        {
            get
            {
                return _ModifiedDate;
            }
            set
            {
                OnModifiedDateChanging(value);
                ReportPropertyChanging("ModifiedDate");
                _ModifiedDate = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("ModifiedDate");
                OnModifiedDateChanged();
            }
        }
        private global::System.DateTime _ModifiedDate;
        partial void OnModifiedDateChanging(global::System.DateTime value);
        partial void OnModifiedDateChanged();

        #endregion
    
        #region Navigation Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_Customer_SalesTerritory_TerritoryID", "Customer")]
        public EntityCollection<Customer> Customers
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Customer>("AdventureWorks_DataModel1.FK_Customer_SalesTerritory_TerritoryID", "Customer");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Customer>("AdventureWorks_DataModel1.FK_Customer_SalesTerritory_TerritoryID", "Customer", value);
                }
            }
        }
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [XmlIgnoreAttribute()]
        [SoapIgnoreAttribute()]
        [DataMemberAttribute()]
        [EdmRelationshipNavigationPropertyAttribute("AdventureWorks_DataModel1", "FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesOrderHeader")]
        public EntityCollection<SalesOrderHeader> SalesOrderHeaders
        {
            get
            {
                return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesOrderHeader");
            }
            set
            {
                if ((value != null))
                {
                    ((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<SalesOrderHeader>("AdventureWorks_DataModel1.FK_SalesOrderHeader_SalesTerritory_TerritoryID", "SalesOrderHeader", value);
                }
            }
        }

        #endregion
    }

    #endregion
    
}
