//------------------------------------------------------------------------------
// <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 Hierarchy_RIA
{
    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 Hierarchy_RIA.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 'Employee' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/Hierarchy_RIA.Web")]
    public sealed partial class Employee : Entity
    {
        
        private string _address;
        
        private Nullable<DateTime> _birthDate;
        
        private string _city;
        
        private string _country;
        
        private EntityRef<Employee> _employee1;
        
        private int _employeeID;
        
        private EntityCollection<Employee> _employees1;
        
        private string _extension;
        
        private string _firstName;
        
        private Nullable<DateTime> _hireDate;
        
        private string _homePhone;
        
        private string _lastName;
        
        private string _notes;
        
        private byte[] _photo;
        
        private string _photoPath;
        
        private string _postalCode;
        
        private string _region;
        
        private Nullable<int> _reportsTo;
        
        private string _title;
        
        private string _titleOfCourtesy;
        
        #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 OnBirthDateChanging(Nullable<DateTime> value);
        partial void OnBirthDateChanged();
        partial void OnCityChanging(string value);
        partial void OnCityChanged();
        partial void OnCountryChanging(string value);
        partial void OnCountryChanged();
        partial void OnEmployeeIDChanging(int value);
        partial void OnEmployeeIDChanged();
        partial void OnExtensionChanging(string value);
        partial void OnExtensionChanged();
        partial void OnFirstNameChanging(string value);
        partial void OnFirstNameChanged();
        partial void OnHireDateChanging(Nullable<DateTime> value);
        partial void OnHireDateChanged();
        partial void OnHomePhoneChanging(string value);
        partial void OnHomePhoneChanged();
        partial void OnLastNameChanging(string value);
        partial void OnLastNameChanged();
        partial void OnNotesChanging(string value);
        partial void OnNotesChanged();
        partial void OnPhotoChanging(byte[] value);
        partial void OnPhotoChanged();
        partial void OnPhotoPathChanging(string value);
        partial void OnPhotoPathChanged();
        partial void OnPostalCodeChanging(string value);
        partial void OnPostalCodeChanged();
        partial void OnRegionChanging(string value);
        partial void OnRegionChanged();
        partial void OnReportsToChanging(Nullable<int> value);
        partial void OnReportsToChanged();
        partial void OnTitleChanging(string value);
        partial void OnTitleChanged();
        partial void OnTitleOfCourtesyChanging(string value);
        partial void OnTitleOfCourtesyChanged();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Employee"/> class.
        /// </summary>
        public Employee()
        {
            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 'BirthDate' value.
        /// </summary>
        [DataMember()]
        public Nullable<DateTime> BirthDate
        {
            get
            {
                return this._birthDate;
            }
            set
            {
                if ((this._birthDate != value))
                {
                    this.OnBirthDateChanging(value);
                    this.RaiseDataMemberChanging("BirthDate");
                    this.ValidateProperty("BirthDate", value);
                    this._birthDate = value;
                    this.RaiseDataMemberChanged("BirthDate");
                    this.OnBirthDateChanged();
                }
            }
        }
        
        /// <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 '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 associated <see cref="Employee"/> entity.
        /// </summary>
        [Association("Employee_Employee", "ReportsTo", "EmployeeID", IsForeignKey=true)]
        [XmlIgnore()]
        public Employee Employee1
        {
            get
            {
                if ((this._employee1 == null))
                {
                    this._employee1 = new EntityRef<Employee>(this, "Employee1", this.FilterEmployee1);
                }
                return this._employee1.Entity;
            }
            set
            {
                Employee previous = this.Employee1;
                if ((previous != value))
                {
                    this.ValidateProperty("Employee1", value);
                    if ((previous != null))
                    {
                        this._employee1.Entity = null;
                        previous.Employees1.Remove(this);
                    }
                    if ((value != null))
                    {
                        this.ReportsTo = value.EmployeeID;
                    }
                    else
                    {
                        this.ReportsTo = default(Nullable<int>);
                    }
                    this._employee1.Entity = value;
                    if ((value != null))
                    {
                        value.Employees1.Add(this);
                    }
                    this.RaisePropertyChanged("Employee1");
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'EmployeeID' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public int EmployeeID
        {
            get
            {
                return this._employeeID;
            }
            set
            {
                if ((this._employeeID != value))
                {
                    this.OnEmployeeIDChanging(value);
                    this.ValidateProperty("EmployeeID", value);
                    this._employeeID = value;
                    this.RaisePropertyChanged("EmployeeID");
                    this.OnEmployeeIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets the collection of associated <see cref="Employee"/> entities.
        /// </summary>
        [Association("Employee_Employee", "EmployeeID", "ReportsTo")]
        [XmlIgnore()]
        public EntityCollection<Employee> Employees1
        {
            get
            {
                if ((this._employees1 == null))
                {
                    this._employees1 = new EntityCollection<Employee>(this, "Employees1", this.FilterEmployees1, this.AttachEmployees1, this.DetachEmployees1);
                }
                return this._employees1;
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Extension' value.
        /// </summary>
        [DataMember()]
        [StringLength(4)]
        public string Extension
        {
            get
            {
                return this._extension;
            }
            set
            {
                if ((this._extension != value))
                {
                    this.OnExtensionChanging(value);
                    this.RaiseDataMemberChanging("Extension");
                    this.ValidateProperty("Extension", value);
                    this._extension = value;
                    this.RaiseDataMemberChanged("Extension");
                    this.OnExtensionChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'FirstName' value.
        /// </summary>
        [DataMember()]
        [Required()]
        [StringLength(10)]
        public string FirstName
        {
            get
            {
                return this._firstName;
            }
            set
            {
                if ((this._firstName != value))
                {
                    this.OnFirstNameChanging(value);
                    this.RaiseDataMemberChanging("FirstName");
                    this.ValidateProperty("FirstName", value);
                    this._firstName = value;
                    this.RaiseDataMemberChanged("FirstName");
                    this.OnFirstNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'HireDate' value.
        /// </summary>
        [DataMember()]
        public Nullable<DateTime> HireDate
        {
            get
            {
                return this._hireDate;
            }
            set
            {
                if ((this._hireDate != value))
                {
                    this.OnHireDateChanging(value);
                    this.RaiseDataMemberChanging("HireDate");
                    this.ValidateProperty("HireDate", value);
                    this._hireDate = value;
                    this.RaiseDataMemberChanged("HireDate");
                    this.OnHireDateChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'HomePhone' value.
        /// </summary>
        [DataMember()]
        [StringLength(24)]
        public string HomePhone
        {
            get
            {
                return this._homePhone;
            }
            set
            {
                if ((this._homePhone != value))
                {
                    this.OnHomePhoneChanging(value);
                    this.RaiseDataMemberChanging("HomePhone");
                    this.ValidateProperty("HomePhone", value);
                    this._homePhone = value;
                    this.RaiseDataMemberChanged("HomePhone");
                    this.OnHomePhoneChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'LastName' value.
        /// </summary>
        [DataMember()]
        [Required()]
        [StringLength(20)]
        public string LastName
        {
            get
            {
                return this._lastName;
            }
            set
            {
                if ((this._lastName != value))
                {
                    this.OnLastNameChanging(value);
                    this.RaiseDataMemberChanging("LastName");
                    this.ValidateProperty("LastName", value);
                    this._lastName = value;
                    this.RaiseDataMemberChanged("LastName");
                    this.OnLastNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Notes' value.
        /// </summary>
        [DataMember()]
        public string Notes
        {
            get
            {
                return this._notes;
            }
            set
            {
                if ((this._notes != value))
                {
                    this.OnNotesChanging(value);
                    this.RaiseDataMemberChanging("Notes");
                    this.ValidateProperty("Notes", value);
                    this._notes = value;
                    this.RaiseDataMemberChanged("Notes");
                    this.OnNotesChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Photo' value.
        /// </summary>
        [DataMember()]
        public byte[] Photo
        {
            get
            {
                return this._photo;
            }
            set
            {
                if ((this._photo != value))
                {
                    this.OnPhotoChanging(value);
                    this.RaiseDataMemberChanging("Photo");
                    this.ValidateProperty("Photo", value);
                    this._photo = value;
                    this.RaiseDataMemberChanged("Photo");
                    this.OnPhotoChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'PhotoPath' value.
        /// </summary>
        [DataMember()]
        [StringLength(255)]
        public string PhotoPath
        {
            get
            {
                return this._photoPath;
            }
            set
            {
                if ((this._photoPath != value))
                {
                    this.OnPhotoPathChanging(value);
                    this.RaiseDataMemberChanging("PhotoPath");
                    this.ValidateProperty("PhotoPath", value);
                    this._photoPath = value;
                    this.RaiseDataMemberChanged("PhotoPath");
                    this.OnPhotoPathChanged();
                }
            }
        }
        
        /// <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();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ReportsTo' value.
        /// </summary>
        [DataMember()]
        [RoundtripOriginal()]
        public Nullable<int> ReportsTo
        {
            get
            {
                return this._reportsTo;
            }
            set
            {
                if ((this._reportsTo != value))
                {
                    this.OnReportsToChanging(value);
                    this.RaiseDataMemberChanging("ReportsTo");
                    this.ValidateProperty("ReportsTo", value);
                    this._reportsTo = value;
                    this.RaiseDataMemberChanged("ReportsTo");
                    this.OnReportsToChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Title' value.
        /// </summary>
        [DataMember()]
        [StringLength(30)]
        public string Title
        {
            get
            {
                return this._title;
            }
            set
            {
                if ((this._title != value))
                {
                    this.OnTitleChanging(value);
                    this.RaiseDataMemberChanging("Title");
                    this.ValidateProperty("Title", value);
                    this._title = value;
                    this.RaiseDataMemberChanged("Title");
                    this.OnTitleChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'TitleOfCourtesy' value.
        /// </summary>
        [DataMember()]
        [StringLength(25)]
        public string TitleOfCourtesy
        {
            get
            {
                return this._titleOfCourtesy;
            }
            set
            {
                if ((this._titleOfCourtesy != value))
                {
                    this.OnTitleOfCourtesyChanging(value);
                    this.RaiseDataMemberChanging("TitleOfCourtesy");
                    this.ValidateProperty("TitleOfCourtesy", value);
                    this._titleOfCourtesy = value;
                    this.RaiseDataMemberChanged("TitleOfCourtesy");
                    this.OnTitleOfCourtesyChanged();
                }
            }
        }
        
        private bool FilterEmployee1(Employee entity)
        {
            return (entity.EmployeeID == this.ReportsTo);
        }
        
        private void AttachEmployees1(Employee entity)
        {
            entity.Employee1 = this;
        }
        
        private void DetachEmployees1(Employee entity)
        {
            entity.Employee1 = null;
        }
        
        private bool FilterEmployees1(Employee entity)
        {
            return (entity.ReportsTo == this.EmployeeID);
        }
        
        /// <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._employeeID;
        }
    }
    
    /// <summary>
    /// The domain context corresponding to the 'EmployeeDomainService' domain service.
    /// </summary>
    public sealed partial class EmployeeDomainContext : 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="EmployeeDomainContext"/> class.
        /// </summary>
        public EmployeeDomainContext() : 
                this(new WebDomainClient<IEmployeeDomainServiceContract>(new Uri("Hierarchy_RIA-Web-EmployeeDomainService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="EmployeeDomainContext"/> class with the specified service URI.
        /// </summary>
        /// <param name="serviceUri">The EmployeeDomainService service URI.</param>
        public EmployeeDomainContext(Uri serviceUri) : 
                this(new WebDomainClient<IEmployeeDomainServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="EmployeeDomainContext"/> class with the specified <paramref name="domainClient"/>.
        /// </summary>
        /// <param name="domainClient">The DomainClient instance to use for this domain context.</param>
        public EmployeeDomainContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the set of <see cref="Employee"/> entities that have been loaded into this <see cref="EmployeeDomainContext"/> instance.
        /// </summary>
        public EntitySet<Employee> Employees
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Employee>();
            }
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="Employee"/> entities using the 'GetEmployees' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Employee"/> entities.</returns>
        public EntityQuery<Employee> GetEmployeesQuery()
        {
            this.ValidateMethod("GetEmployeesQuery", null);
            return base.CreateQuery<Employee>("GetEmployees", 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 EmployeeDomainContextEntityContainer();
        }
        
        /// <summary>
        /// Service contract for the 'EmployeeDomainService' domain service.
        /// </summary>
        [ServiceContract()]
        public interface IEmployeeDomainServiceContract
        {
            
            /// <summary>
            /// Asynchronously invokes the 'GetEmployees' operation.
            /// </summary>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/EmployeeDomainService/GetEmployeesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/EmployeeDomainService/GetEmployees", ReplyAction="http://tempuri.org/EmployeeDomainService/GetEmployeesResponse")]
            [WebGet()]
            IAsyncResult BeginGetEmployees(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetEmployees'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetEmployees'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetEmployees' operation.</returns>
            QueryResult<Employee> EndGetEmployees(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/EmployeeDomainService/SubmitChangesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/EmployeeDomainService/SubmitChanges", ReplyAction="http://tempuri.org/EmployeeDomainService/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 EmployeeDomainContextEntityContainer : EntityContainer
        {
            
            public EmployeeDomainContextEntityContainer()
            {
                this.CreateEntitySet<Employee>(EntitySetOperations.All);
            }
        }
    }
    
    /// <summary>
    /// The domain context corresponding to the 'NWDomainService' domain service.
    /// </summary>
    public sealed partial class NWDomainContext : 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="NWDomainContext"/> class.
        /// </summary>
        public NWDomainContext() : 
                this(new WebDomainClient<INWDomainServiceContract>(new Uri("Hierarchy_RIA-Web-NWDomainService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="NWDomainContext"/> class with the specified service URI.
        /// </summary>
        /// <param name="serviceUri">The NWDomainService service URI.</param>
        public NWDomainContext(Uri serviceUri) : 
                this(new WebDomainClient<INWDomainServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="NWDomainContext"/> class with the specified <paramref name="domainClient"/>.
        /// </summary>
        /// <param name="domainClient">The DomainClient instance to use for this domain context.</param>
        public NWDomainContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the set of <see cref="Order_Detail"/> entities that have been loaded into this <see cref="NWDomainContext"/> instance.
        /// </summary>
        public EntitySet<Order_Detail> Order_Details
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Order_Detail>();
            }
        }
        
        /// <summary>
        /// Gets the set of <see cref="Order"/> entities that have been loaded into this <see cref="NWDomainContext"/> 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="Order_Detail"/> entities using the 'GetOrder_Details' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Order_Detail"/> entities.</returns>
        public EntityQuery<Order_Detail> GetOrder_DetailsQuery()
        {
            this.ValidateMethod("GetOrder_DetailsQuery", null);
            return base.CreateQuery<Order_Detail>("GetOrder_Details", 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 NWDomainContextEntityContainer();
        }
        
        /// <summary>
        /// Service contract for the 'NWDomainService' domain service.
        /// </summary>
        [ServiceContract()]
        public interface INWDomainServiceContract
        {
            
            /// <summary>
            /// Asynchronously invokes the 'GetOrder_Details' operation.
            /// </summary>
            /// <param name="callback">Callback to invoke on completion.</param>
            /// <param name="asyncState">Optional state object.</param>
            /// <returns>An IAsyncResult that can be used to monitor the request.</returns>
            [FaultContract(typeof(DomainServiceFault), Action="http://tempuri.org/NWDomainService/GetOrder_DetailsDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/NWDomainService/GetOrder_Details", ReplyAction="http://tempuri.org/NWDomainService/GetOrder_DetailsResponse")]
            [WebGet()]
            IAsyncResult BeginGetOrder_Details(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetOrder_Details'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetOrder_Details'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetOrder_Details' operation.</returns>
            QueryResult<Order_Detail> EndGetOrder_Details(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/NWDomainService/GetOrdersDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/NWDomainService/GetOrders", ReplyAction="http://tempuri.org/NWDomainService/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/NWDomainService/SubmitChangesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/NWDomainService/SubmitChanges", ReplyAction="http://tempuri.org/NWDomainService/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 NWDomainContextEntityContainer : EntityContainer
        {
            
            public NWDomainContextEntityContainer()
            {
                this.CreateEntitySet<Order>(EntitySetOperations.All);
                this.CreateEntitySet<Order_Detail>(EntitySetOperations.All);
            }
        }
    }
    
    /// <summary>
    /// The 'Order' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/Hierarchy_RIA.Web")]
    public sealed partial class Order : Entity
    {
        
        private string _customerID;
        
        private Nullable<int> _employeeID;
        
        private Nullable<decimal> _freight;
        
        private decimal _maxUnitPrice;
        
        private EntityCollection<Order_Detail> _order_Details;
        
        private Nullable<DateTime> _orderDate;
        
        private int _orderID;
        
        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 OnMaxUnitPriceChanging(decimal value);
        partial void OnMaxUnitPriceChanged();
        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 '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()]
        [RoundtripOriginal()]
        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 'MaxUnitPrice' value.
        /// </summary>
        [DataMember()]
        [Editable(false)]
        [ReadOnly(true)]
        public decimal MaxUnitPrice
        {
            get
            {
                return this._maxUnitPrice;
            }
            set
            {
                if ((this._maxUnitPrice != value))
                {
                    this.OnMaxUnitPriceChanging(value);
                    this.ValidateProperty("MaxUnitPrice", value);
                    this._maxUnitPrice = value;
                    this.RaisePropertyChanged("MaxUnitPrice");
                    this.OnMaxUnitPriceChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets the collection of associated <see cref="Order_Detail"/> entities.
        /// </summary>
        [Association("Order_Order_Detail", "OrderID", "OrderID")]
        [XmlIgnore()]
        public EntityCollection<Order_Detail> Order_Details
        {
            get
            {
                if ((this._order_Details == null))
                {
                    this._order_Details = new EntityCollection<Order_Detail>(this, "Order_Details", this.FilterOrder_Details, this.AttachOrder_Details, this.DetachOrder_Details);
                }
                return this._order_Details;
            }
        }
        
        /// <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()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public int OrderID
        {
            get
            {
                return this._orderID;
            }
            set
            {
                if ((this._orderID != value))
                {
                    this.OnOrderIDChanging(value);
                    this.ValidateProperty("OrderID", value);
                    this._orderID = value;
                    this.RaisePropertyChanged("OrderID");
                    this.OnOrderIDChanged();
                }
            }
        }
        
        /// <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()]
        [RoundtripOriginal()]
        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 void AttachOrder_Details(Order_Detail entity)
        {
            entity.Order = this;
        }
        
        private void DetachOrder_Details(Order_Detail entity)
        {
            entity.Order = null;
        }
        
        private bool FilterOrder_Details(Order_Detail 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;
        }
    }
    
    /// <summary>
    /// The 'Order_Detail' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/Hierarchy_RIA.Web")]
    public sealed partial class Order_Detail : Entity
    {
        
        private float _discount;
        
        private EntityRef<Order> _order;
        
        private int _orderID;
        
        private int _productID;
        
        private short _quantity;
        
        private decimal _unitPrice;
        
        #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 OnDiscountChanging(float value);
        partial void OnDiscountChanged();
        partial void OnOrderIDChanging(int value);
        partial void OnOrderIDChanged();
        partial void OnProductIDChanging(int value);
        partial void OnProductIDChanged();
        partial void OnQuantityChanging(short value);
        partial void OnQuantityChanged();
        partial void OnUnitPriceChanging(decimal value);
        partial void OnUnitPriceChanged();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Order_Detail"/> class.
        /// </summary>
        public Order_Detail()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets or sets the 'Discount' value.
        /// </summary>
        [DataMember()]
        public float Discount
        {
            get
            {
                return this._discount;
            }
            set
            {
                if ((this._discount != value))
                {
                    this.OnDiscountChanging(value);
                    this.RaiseDataMemberChanging("Discount");
                    this.ValidateProperty("Discount", value);
                    this._discount = value;
                    this.RaiseDataMemberChanged("Discount");
                    this.OnDiscountChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the associated <see cref="Order"/> entity.
        /// </summary>
        [Association("Order_Order_Detail", "OrderID", "OrderID", IsForeignKey=true)]
        [XmlIgnore()]
        public Order Order
        {
            get
            {
                if ((this._order == null))
                {
                    this._order = new EntityRef<Order>(this, "Order", this.FilterOrder);
                }
                return this._order.Entity;
            }
            set
            {
                Order previous = this.Order;
                if ((previous != value))
                {
                    this.ValidateProperty("Order", value);
                    if ((previous != null))
                    {
                        this._order.Entity = null;
                        previous.Order_Details.Remove(this);
                    }
                    if ((value != null))
                    {
                        this.OrderID = value.OrderID;
                    }
                    else
                    {
                        this.OrderID = default(int);
                    }
                    this._order.Entity = value;
                    if ((value != null))
                    {
                        value.Order_Details.Add(this);
                    }
                    this.RaisePropertyChanged("Order");
                }
            }
        }
        
        /// <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 'ProductID' value.
        /// </summary>
        [DataMember()]
        [Key()]
        [RoundtripOriginal()]
        public int ProductID
        {
            get
            {
                return this._productID;
            }
            set
            {
                if ((this._productID != value))
                {
                    this.OnProductIDChanging(value);
                    this.RaiseDataMemberChanging("ProductID");
                    this.ValidateProperty("ProductID", value);
                    this._productID = value;
                    this.RaiseDataMemberChanged("ProductID");
                    this.OnProductIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Quantity' value.
        /// </summary>
        [DataMember()]
        public short Quantity
        {
            get
            {
                return this._quantity;
            }
            set
            {
                if ((this._quantity != value))
                {
                    this.OnQuantityChanging(value);
                    this.RaiseDataMemberChanging("Quantity");
                    this.ValidateProperty("Quantity", value);
                    this._quantity = value;
                    this.RaiseDataMemberChanged("Quantity");
                    this.OnQuantityChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'UnitPrice' value.
        /// </summary>
        [DataMember()]
        public decimal UnitPrice
        {
            get
            {
                return this._unitPrice;
            }
            set
            {
                if ((this._unitPrice != value))
                {
                    this.OnUnitPriceChanging(value);
                    this.RaiseDataMemberChanging("UnitPrice");
                    this.ValidateProperty("UnitPrice", value);
                    this._unitPrice = value;
                    this.RaiseDataMemberChanged("UnitPrice");
                    this.OnUnitPriceChanged();
                }
            }
        }
        
        private bool FilterOrder(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 EntityKey.Create(this._orderID, this._productID);
        }
    }
}
