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

namespace GridViewInDataForm
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.ServiceModel.DomainServices;
    using System.ServiceModel.DomainServices.Client;
    using System.ServiceModel.DomainServices.Client.ApplicationServices;
    
    
    /// <summary>
    /// Context for the RIA application.
    /// </summary>
    /// <remarks>
    /// This context extends the base to make application services and types available
    /// for consumption from code and xaml.
    /// </remarks>
    public sealed partial class WebContext : WebContextBase
    {
        
        #region Extensibility Method Definitions

        /// <summary>
        /// This method is invoked from the constructor once initialization is complete and
        /// can be used for further object setup.
        /// </summary>
        partial void OnCreated();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the WebContext class.
        /// </summary>
        public WebContext()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the context that is registered as a lifetime object with the current application.
        /// </summary>
        /// <exception cref="InvalidOperationException"> is thrown if there is no current application,
        /// no contexts have been added, or more than one context has been added.
        /// </exception>
        /// <seealso cref="System.Windows.Application.ApplicationLifetimeObjects"/>
        public new static WebContext Current
        {
            get
            {
                return ((WebContext)(WebContextBase.Current));
            }
        }
    }
}
namespace GridViewInDataForm.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.ServiceModel;
    using System.ServiceModel.DomainServices;
    using System.ServiceModel.DomainServices.Client;
    using System.ServiceModel.DomainServices.Client.ApplicationServices;
    using System.ServiceModel.Web;
    using System.Xml.Serialization;
    
    
    /// <summary>
    /// The 'Customer' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/GridViewInDataForm.Web")]
    public sealed partial class Customer : Entity
    {
        
        private string _address;
        
        private string _city;
        
        private string _companyName;
        
        private string _contactName;
        
        private string _contactTitle;
        
        private string _country;
        
        private string _customerID;
        
        private string _fax;
        
        private EntityCollection<Order> _orders;
        
        private string _phone;
        
        private string _postalCode;
        
        private string _region;
        
        #region Extensibility Method Definitions

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

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Customer"/> class.
        /// </summary>
        public Customer()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets or sets the 'Address' value.
        /// </summary>
        [DataMember()]
        [StringLength(60)]
        public string Address
        {
            get
            {
                return this._address;
            }
            set
            {
                if ((this._address != value))
                {
                    this.OnAddressChanging(value);
                    this.RaiseDataMemberChanging("Address");
                    this.ValidateProperty("Address", value);
                    this._address = value;
                    this.RaiseDataMemberChanged("Address");
                    this.OnAddressChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'City' value.
        /// </summary>
        [DataMember()]
        [StringLength(15)]
        public string City
        {
            get
            {
                return this._city;
            }
            set
            {
                if ((this._city != value))
                {
                    this.OnCityChanging(value);
                    this.RaiseDataMemberChanging("City");
                    this.ValidateProperty("City", value);
                    this._city = value;
                    this.RaiseDataMemberChanged("City");
                    this.OnCityChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'CompanyName' value.
        /// </summary>
        [DataMember()]
        [Required()]
        [StringLength(40)]
        public string CompanyName
        {
            get
            {
                return this._companyName;
            }
            set
            {
                if ((this._companyName != value))
                {
                    this.OnCompanyNameChanging(value);
                    this.RaiseDataMemberChanging("CompanyName");
                    this.ValidateProperty("CompanyName", value);
                    this._companyName = value;
                    this.RaiseDataMemberChanged("CompanyName");
                    this.OnCompanyNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ContactName' value.
        /// </summary>
        [DataMember()]
        [StringLength(30)]
        public string ContactName
        {
            get
            {
                return this._contactName;
            }
            set
            {
                if ((this._contactName != value))
                {
                    this.OnContactNameChanging(value);
                    this.RaiseDataMemberChanging("ContactName");
                    this.ValidateProperty("ContactName", value);
                    this._contactName = value;
                    this.RaiseDataMemberChanged("ContactName");
                    this.OnContactNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ContactTitle' value.
        /// </summary>
        [DataMember()]
        [StringLength(30)]
        public string ContactTitle
        {
            get
            {
                return this._contactTitle;
            }
            set
            {
                if ((this._contactTitle != value))
                {
                    this.OnContactTitleChanging(value);
                    this.RaiseDataMemberChanging("ContactTitle");
                    this.ValidateProperty("ContactTitle", value);
                    this._contactTitle = value;
                    this.RaiseDataMemberChanged("ContactTitle");
                    this.OnContactTitleChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Country' value.
        /// </summary>
        [DataMember()]
        [StringLength(15)]
        public string Country
        {
            get
            {
                return this._country;
            }
            set
            {
                if ((this._country != value))
                {
                    this.OnCountryChanging(value);
                    this.RaiseDataMemberChanging("Country");
                    this.ValidateProperty("Country", value);
                    this._country = value;
                    this.RaiseDataMemberChanged("Country");
                    this.OnCountryChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'CustomerID' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [Required()]
        [RoundtripOriginal()]
        [StringLength(5)]
        public string CustomerID
        {
            get
            {
                return this._customerID;
            }
            set
            {
                if ((this._customerID != value))
                {
                    this.OnCustomerIDChanging(value);
                    this.ValidateProperty("CustomerID", value);
                    this._customerID = value;
                    this.RaisePropertyChanged("CustomerID");
                    this.OnCustomerIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Fax' value.
        /// </summary>
        [DataMember()]
        [StringLength(24)]
        public string Fax
        {
            get
            {
                return this._fax;
            }
            set
            {
                if ((this._fax != value))
                {
                    this.OnFaxChanging(value);
                    this.RaiseDataMemberChanging("Fax");
                    this.ValidateProperty("Fax", value);
                    this._fax = value;
                    this.RaiseDataMemberChanged("Fax");
                    this.OnFaxChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets the collection of associated <see cref="Order"/> entities.
        /// </summary>
        [Association("Customer_Order", "CustomerID", "CustomerID")]
        [XmlIgnore()]
        public EntityCollection<Order> Orders
        {
            get
            {
                if ((this._orders == null))
                {
                    this._orders = new EntityCollection<Order>(this, "Orders", this.FilterOrders, this.AttachOrders, this.DetachOrders);
                }
                return this._orders;
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Phone' value.
        /// </summary>
        [DataMember()]
        [StringLength(24)]
        public string Phone
        {
            get
            {
                return this._phone;
            }
            set
            {
                if ((this._phone != value))
                {
                    this.OnPhoneChanging(value);
                    this.RaiseDataMemberChanging("Phone");
                    this.ValidateProperty("Phone", value);
                    this._phone = value;
                    this.RaiseDataMemberChanged("Phone");
                    this.OnPhoneChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'PostalCode' value.
        /// </summary>
        [DataMember()]
        [StringLength(10)]
        public string PostalCode
        {
            get
            {
                return this._postalCode;
            }
            set
            {
                if ((this._postalCode != value))
                {
                    this.OnPostalCodeChanging(value);
                    this.RaiseDataMemberChanging("PostalCode");
                    this.ValidateProperty("PostalCode", value);
                    this._postalCode = value;
                    this.RaiseDataMemberChanged("PostalCode");
                    this.OnPostalCodeChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Region' value.
        /// </summary>
        [DataMember()]
        [StringLength(15)]
        public string Region
        {
            get
            {
                return this._region;
            }
            set
            {
                if ((this._region != value))
                {
                    this.OnRegionChanging(value);
                    this.RaiseDataMemberChanging("Region");
                    this.ValidateProperty("Region", value);
                    this._region = value;
                    this.RaiseDataMemberChanged("Region");
                    this.OnRegionChanged();
                }
            }
        }
        
        private void AttachOrders(Order entity)
        {
            entity.Customer = this;
        }
        
        private void DetachOrders(Order entity)
        {
            entity.Customer = null;
        }
        
        private bool FilterOrders(Order entity)
        {
            return (entity.CustomerID == this.CustomerID);
        }
        
        /// <summary>
        /// Computes a value from the key fields that uniquely identifies this entity instance.
        /// </summary>
        /// <returns>An object instance that uniquely identifies this entity instance.</returns>
        public override object GetIdentity()
        {
            return this._customerID;
        }
    }
    
    /// <summary>
    /// The domain context corresponding to the 'CustomersDomainService' domain service.
    /// </summary>
    public sealed partial class CustomersDomainContext : DomainContext
    {
        
        #region Extensibility Method Definitions

        /// <summary>
        /// This method is invoked from the constructor once initialization is complete and
        /// can be used for further object setup.
        /// </summary>
        partial void OnCreated();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomersDomainContext"/> class.
        /// </summary>
        public CustomersDomainContext() : 
                this(new WebDomainClient<ICustomersDomainServiceContract>(new Uri("GridViewInDataForm-Web-CustomersDomainService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomersDomainContext"/> class with the specified service URI.
        /// </summary>
        /// <param name="serviceUri">The CustomersDomainService service URI.</param>
        public CustomersDomainContext(Uri serviceUri) : 
                this(new WebDomainClient<ICustomersDomainServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="CustomersDomainContext"/> class with the specified <paramref name="domainClient"/>.
        /// </summary>
        /// <param name="domainClient">The DomainClient instance to use for this domain context.</param>
        public CustomersDomainContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the set of <see cref="Customer"/> entities that have been loaded into this <see cref="CustomersDomainContext"/> instance.
        /// </summary>
        public EntitySet<Customer> Customers
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Customer>();
            }
        }
        
        /// <summary>
        /// Gets the set of <see cref="Order"/> entities that have been loaded into this <see cref="CustomersDomainContext"/> instance.
        /// </summary>
        public EntitySet<Order> Orders
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Order>();
            }
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="Customer"/> entities using the 'GetCustomers' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Customer"/> entities.</returns>
        public EntityQuery<Customer> GetCustomersQuery()
        {
            this.ValidateMethod("GetCustomersQuery", null);
            return base.CreateQuery<Customer>("GetCustomers", null, false, true);
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="Order"/> entities using the 'GetOrders' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Order"/> entities.</returns>
        public EntityQuery<Order> GetOrdersQuery()
        {
            this.ValidateMethod("GetOrdersQuery", null);
            return base.CreateQuery<Order>("GetOrders", null, false, true);
        }
        
        /// <summary>
        /// Creates a new entity container for this domain context's entity sets.
        /// </summary>
        /// <returns>A new container instance.</returns>
        protected override EntityContainer CreateEntityContainer()
        {
            return new CustomersDomainContextEntityContainer();
        }
        
        /// <summary>
        /// Service contract for the 'CustomersDomainService' domain service.
        /// </summary>
        [ServiceContract()]
        public interface ICustomersDomainServiceContract
        {
            
            /// <summary>
            /// Asynchronously invokes the 'GetCustomers' operation.
            /// </summary>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/CustomersDomainService/GetCustomersDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/CustomersDomainService/GetCustomers", ReplyAction="http://tempuri.org/CustomersDomainService/GetCustomersResponse")]
            [WebGet()]
            IAsyncResult BeginGetCustomers(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetCustomers'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetCustomers'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetCustomers' operation.</returns>
            QueryResult<Customer> EndGetCustomers(IAsyncResult result);
            
            /// <summary>
            /// Asynchronously invokes the 'GetOrders' operation.
            /// </summary>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/CustomersDomainService/GetOrdersDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/CustomersDomainService/GetOrders", ReplyAction="http://tempuri.org/CustomersDomainService/GetOrdersResponse")]
            [WebGet()]
            IAsyncResult BeginGetOrders(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetOrders'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetOrders'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetOrders' operation.</returns>
            QueryResult<Order> EndGetOrders(IAsyncResult result);
            
            /// <summary>
            /// Asynchronously invokes the 'SubmitChanges' operation.
            /// </summary>
            /// <param name="changeSet">The change-set to submit.</param>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/CustomersDomainService/SubmitChangesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/CustomersDomainService/SubmitChanges", ReplyAction="http://tempuri.org/CustomersDomainService/SubmitChangesResponse")]
            IAsyncResult BeginSubmitChanges(IEnumerable<ChangeSetEntry> changeSet, AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginSubmitChanges'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginSubmitChanges'.</param>
            /// <returns>The collection of change-set entry elements returned from 'SubmitChanges'.</returns>
            IEnumerable<ChangeSetEntry> EndSubmitChanges(IAsyncResult result);
        }
        
        internal sealed class CustomersDomainContextEntityContainer : EntityContainer
        {
            
            public CustomersDomainContextEntityContainer()
            {
                this.CreateEntitySet<Customer>(EntitySetOperations.All);
                this.CreateEntitySet<Order>(EntitySetOperations.All);
            }
        }
    }
    
    /// <summary>
    /// The 'Order' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/GridViewInDataForm.Web")]
    public sealed partial class Order : Entity
    {
        
        private EntityRef<Customer> _customer;
        
        private string _customerID;
        
        private Nullable<int> _employeeID;
        
        private Nullable<decimal> _freight;
        
        private EntityRef<Order> _order1;
        
        private Nullable<DateTime> _orderDate;
        
        private int _orderID;
        
        private EntityRef<Order> _orders1;
        
        private Nullable<DateTime> _requiredDate;
        
        private string _shipAddress;
        
        private string _shipCity;
        
        private string _shipCountry;
        
        private string _shipName;
        
        private Nullable<DateTime> _shippedDate;
        
        private string _shipPostalCode;
        
        private string _shipRegion;
        
        private Nullable<int> _shipVia;
        
        #region Extensibility Method Definitions

        /// <summary>
        /// This method is invoked from the constructor once initialization is complete and
        /// can be used for further object setup.
        /// </summary>
        partial void OnCreated();
        partial void OnCustomerIDChanging(string value);
        partial void OnCustomerIDChanged();
        partial void OnEmployeeIDChanging(Nullable<int> value);
        partial void OnEmployeeIDChanged();
        partial void OnFreightChanging(Nullable<decimal> value);
        partial void OnFreightChanged();
        partial void OnOrderDateChanging(Nullable<DateTime> value);
        partial void OnOrderDateChanged();
        partial void OnOrderIDChanging(int value);
        partial void OnOrderIDChanged();
        partial void OnRequiredDateChanging(Nullable<DateTime> value);
        partial void OnRequiredDateChanged();
        partial void OnShipAddressChanging(string value);
        partial void OnShipAddressChanged();
        partial void OnShipCityChanging(string value);
        partial void OnShipCityChanged();
        partial void OnShipCountryChanging(string value);
        partial void OnShipCountryChanged();
        partial void OnShipNameChanging(string value);
        partial void OnShipNameChanged();
        partial void OnShippedDateChanging(Nullable<DateTime> value);
        partial void OnShippedDateChanged();
        partial void OnShipPostalCodeChanging(string value);
        partial void OnShipPostalCodeChanged();
        partial void OnShipRegionChanging(string value);
        partial void OnShipRegionChanged();
        partial void OnShipViaChanging(Nullable<int> value);
        partial void OnShipViaChanged();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Order"/> class.
        /// </summary>
        public Order()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets or sets the associated <see cref="Customer"/> entity.
        /// </summary>
        [Association("Customer_Order", "CustomerID", "CustomerID", IsForeignKey=true)]
        [XmlIgnore()]
        public Customer Customer
        {
            get
            {
                if ((this._customer == null))
                {
                    this._customer = new EntityRef<Customer>(this, "Customer", this.FilterCustomer);
                }
                return this._customer.Entity;
            }
            set
            {
                Customer previous = this.Customer;
                if ((previous != value))
                {
                    this.ValidateProperty("Customer", value);
                    if ((previous != null))
                    {
                        this._customer.Entity = null;
                        previous.Orders.Remove(this);
                    }
                    if ((value != null))
                    {
                        this.CustomerID = value.CustomerID;
                    }
                    else
                    {
                        this.CustomerID = default(string);
                    }
                    this._customer.Entity = value;
                    if ((value != null))
                    {
                        value.Orders.Add(this);
                    }
                    this.RaisePropertyChanged("Customer");
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'CustomerID' value.
        /// </summary>
        [DataMember()]
        [RoundtripOriginal()]
        [StringLength(5)]
        public string CustomerID
        {
            get
            {
                return this._customerID;
            }
            set
            {
                if ((this._customerID != value))
                {
                    this.OnCustomerIDChanging(value);
                    this.RaiseDataMemberChanging("CustomerID");
                    this.ValidateProperty("CustomerID", value);
                    this._customerID = value;
                    this.RaiseDataMemberChanged("CustomerID");
                    this.OnCustomerIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'EmployeeID' value.
        /// </summary>
        [DataMember()]
        public Nullable<int> EmployeeID
        {
            get
            {
                return this._employeeID;
            }
            set
            {
                if ((this._employeeID != value))
                {
                    this.OnEmployeeIDChanging(value);
                    this.RaiseDataMemberChanging("EmployeeID");
                    this.ValidateProperty("EmployeeID", value);
                    this._employeeID = value;
                    this.RaiseDataMemberChanged("EmployeeID");
                    this.OnEmployeeIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Freight' value.
        /// </summary>
        [DataMember()]
        public Nullable<decimal> Freight
        {
            get
            {
                return this._freight;
            }
            set
            {
                if ((this._freight != value))
                {
                    this.OnFreightChanging(value);
                    this.RaiseDataMemberChanging("Freight");
                    this.ValidateProperty("Freight", value);
                    this._freight = value;
                    this.RaiseDataMemberChanged("Freight");
                    this.OnFreightChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the associated <see cref="Order"/> entity.
        /// </summary>
        [Association("Order_Order", "OrderID", "OrderID", IsForeignKey=true)]
        [XmlIgnore()]
        public Order Order1
        {
            get
            {
                if ((this._order1 == null))
                {
                    this._order1 = new EntityRef<Order>(this, "Order1", this.FilterOrder1);
                }
                return this._order1.Entity;
            }
            set
            {
                Order previous = this.Order1;
                if ((previous != value))
                {
                    this.ValidateProperty("Order1", value);
                    if ((previous != null))
                    {
                        this._order1.Entity = null;
                        previous.Orders1 = null;
                    }
                    if ((value != null))
                    {
                        this.OrderID = value.OrderID;
                    }
                    else
                    {
                        this.OrderID = default(int);
                    }
                    this._order1.Entity = value;
                    if ((value != null))
                    {
                        value.Orders1 = this;
                    }
                    this.RaisePropertyChanged("Order1");
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'OrderDate' value.
        /// </summary>
        [DataMember()]
        public Nullable<DateTime> OrderDate
        {
            get
            {
                return this._orderDate;
            }
            set
            {
                if ((this._orderDate != value))
                {
                    this.OnOrderDateChanging(value);
                    this.RaiseDataMemberChanging("OrderDate");
                    this.ValidateProperty("OrderDate", value);
                    this._orderDate = value;
                    this.RaiseDataMemberChanged("OrderDate");
                    this.OnOrderDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'OrderID' value.
        /// </summary>
        [DataMember()]
        [Key()]
        [RoundtripOriginal()]
        public int OrderID
        {
            get
            {
                return this._orderID;
            }
            set
            {
                if ((this._orderID != value))
                {
                    this.OnOrderIDChanging(value);
                    this.RaiseDataMemberChanging("OrderID");
                    this.ValidateProperty("OrderID", value);
                    this._orderID = value;
                    this.RaiseDataMemberChanged("OrderID");
                    this.OnOrderIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the associated <see cref="Order"/> entity.
        /// </summary>
        [Association("Order_Order", "OrderID", "OrderID")]
        [XmlIgnore()]
        public Order Orders1
        {
            get
            {
                if ((this._orders1 == null))
                {
                    this._orders1 = new EntityRef<Order>(this, "Orders1", this.FilterOrders1);
                }
                return this._orders1.Entity;
            }
            set
            {
                Order previous = this.Orders1;
                if ((previous != value))
                {
                    this.ValidateProperty("Orders1", value);
                    if ((previous != null))
                    {
                        this._orders1.Entity = null;
                        previous.Order1 = null;
                    }
                    this._orders1.Entity = value;
                    if ((value != null))
                    {
                        value.Order1 = this;
                    }
                    this.RaisePropertyChanged("Orders1");
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'RequiredDate' value.
        /// </summary>
        [DataMember()]
        public Nullable<DateTime> RequiredDate
        {
            get
            {
                return this._requiredDate;
            }
            set
            {
                if ((this._requiredDate != value))
                {
                    this.OnRequiredDateChanging(value);
                    this.RaiseDataMemberChanging("RequiredDate");
                    this.ValidateProperty("RequiredDate", value);
                    this._requiredDate = value;
                    this.RaiseDataMemberChanged("RequiredDate");
                    this.OnRequiredDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShipAddress' value.
        /// </summary>
        [DataMember()]
        [StringLength(60)]
        public string ShipAddress
        {
            get
            {
                return this._shipAddress;
            }
            set
            {
                if ((this._shipAddress != value))
                {
                    this.OnShipAddressChanging(value);
                    this.RaiseDataMemberChanging("ShipAddress");
                    this.ValidateProperty("ShipAddress", value);
                    this._shipAddress = value;
                    this.RaiseDataMemberChanged("ShipAddress");
                    this.OnShipAddressChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShipCity' value.
        /// </summary>
        [DataMember()]
        [StringLength(15)]
        public string ShipCity
        {
            get
            {
                return this._shipCity;
            }
            set
            {
                if ((this._shipCity != value))
                {
                    this.OnShipCityChanging(value);
                    this.RaiseDataMemberChanging("ShipCity");
                    this.ValidateProperty("ShipCity", value);
                    this._shipCity = value;
                    this.RaiseDataMemberChanged("ShipCity");
                    this.OnShipCityChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShipCountry' value.
        /// </summary>
        [DataMember()]
        [StringLength(15)]
        public string ShipCountry
        {
            get
            {
                return this._shipCountry;
            }
            set
            {
                if ((this._shipCountry != value))
                {
                    this.OnShipCountryChanging(value);
                    this.RaiseDataMemberChanging("ShipCountry");
                    this.ValidateProperty("ShipCountry", value);
                    this._shipCountry = value;
                    this.RaiseDataMemberChanged("ShipCountry");
                    this.OnShipCountryChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShipName' value.
        /// </summary>
        [DataMember()]
        [StringLength(40)]
        public string ShipName
        {
            get
            {
                return this._shipName;
            }
            set
            {
                if ((this._shipName != value))
                {
                    this.OnShipNameChanging(value);
                    this.RaiseDataMemberChanging("ShipName");
                    this.ValidateProperty("ShipName", value);
                    this._shipName = value;
                    this.RaiseDataMemberChanged("ShipName");
                    this.OnShipNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShippedDate' value.
        /// </summary>
        [DataMember()]
        public Nullable<DateTime> ShippedDate
        {
            get
            {
                return this._shippedDate;
            }
            set
            {
                if ((this._shippedDate != value))
                {
                    this.OnShippedDateChanging(value);
                    this.RaiseDataMemberChanging("ShippedDate");
                    this.ValidateProperty("ShippedDate", value);
                    this._shippedDate = value;
                    this.RaiseDataMemberChanged("ShippedDate");
                    this.OnShippedDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShipPostalCode' value.
        /// </summary>
        [DataMember()]
        [StringLength(10)]
        public string ShipPostalCode
        {
            get
            {
                return this._shipPostalCode;
            }
            set
            {
                if ((this._shipPostalCode != value))
                {
                    this.OnShipPostalCodeChanging(value);
                    this.RaiseDataMemberChanging("ShipPostalCode");
                    this.ValidateProperty("ShipPostalCode", value);
                    this._shipPostalCode = value;
                    this.RaiseDataMemberChanged("ShipPostalCode");
                    this.OnShipPostalCodeChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShipRegion' value.
        /// </summary>
        [DataMember()]
        [StringLength(15)]
        public string ShipRegion
        {
            get
            {
                return this._shipRegion;
            }
            set
            {
                if ((this._shipRegion != value))
                {
                    this.OnShipRegionChanging(value);
                    this.RaiseDataMemberChanging("ShipRegion");
                    this.ValidateProperty("ShipRegion", value);
                    this._shipRegion = value;
                    this.RaiseDataMemberChanged("ShipRegion");
                    this.OnShipRegionChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ShipVia' value.
        /// </summary>
        [DataMember()]
        public Nullable<int> ShipVia
        {
            get
            {
                return this._shipVia;
            }
            set
            {
                if ((this._shipVia != value))
                {
                    this.OnShipViaChanging(value);
                    this.RaiseDataMemberChanging("ShipVia");
                    this.ValidateProperty("ShipVia", value);
                    this._shipVia = value;
                    this.RaiseDataMemberChanged("ShipVia");
                    this.OnShipViaChanged();
                }
            }
        }
        
        private bool FilterCustomer(Customer entity)
        {
            return (entity.CustomerID == this.CustomerID);
        }
        
        private bool FilterOrder1(Order entity)
        {
            return (entity.OrderID == this.OrderID);
        }
        
        private bool FilterOrders1(Order entity)
        {
            return (entity.OrderID == this.OrderID);
        }
        
        /// <summary>
        /// Computes a value from the key fields that uniquely identifies this entity instance.
        /// </summary>
        /// <returns>An object instance that uniquely identifies this entity instance.</returns>
        public override object GetIdentity()
        {
            return this._orderID;
        }
    }
}
