//------------------------------------------------------------------------------
// <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 CRUDSampleApplication
{
    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 CRUDSampleApplication.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;
    
    
    /// <summary>
    /// The domain context corresponding to the 'NorthwindService' domain service.
    /// </summary>
    public sealed partial class NorthwindContext : 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="NorthwindContext"/> class.
        /// </summary>
        public NorthwindContext() : 
                this(new WebDomainClient<INorthwindServiceContract>(new Uri("CRUDSampleApplication-Web-NorthwindService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="NorthwindContext"/> class with the specified service URI.
        /// </summary>
        /// <param name="serviceUri">The NorthwindService service URI.</param>
        public NorthwindContext(Uri serviceUri) : 
                this(new WebDomainClient<INorthwindServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="NorthwindContext"/> class with the specified <paramref name="domainClient"/>.
        /// </summary>
        /// <param name="domainClient">The DomainClient instance to use for this domain context.</param>
        public NorthwindContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the set of <see cref="Order_Detail"/> entities that have been loaded into this <see cref="NorthwindContext"/> instance.
        /// </summary>
        public EntitySet<Order_Detail> Order_Details
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Order_Detail>();
            }
        }
        
        /// <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>
        /// 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 NorthwindContextEntityContainer();
        }
        
        /// <summary>
        /// Service contract for the 'NorthwindService' domain service.
        /// </summary>
        [ServiceContract()]
        public interface INorthwindServiceContract
        {
            
            /// <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/NorthwindService/GetOrder_DetailsDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/NorthwindService/GetOrder_Details", ReplyAction="http://tempuri.org/NorthwindService/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 '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/NorthwindService/SubmitChangesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/NorthwindService/SubmitChanges", ReplyAction="http://tempuri.org/NorthwindService/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 NorthwindContextEntityContainer : EntityContainer
        {
            
            public NorthwindContextEntityContainer()
            {
                this.CreateEntitySet<Order_Detail>(EntitySetOperations.All);
            }
        }
    }
    
    /// <summary>
    /// The 'Order_Detail' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/CRUDSampleApplication.Web")]
    public sealed partial class Order_Detail : Entity
    {
        
        private float _discount;
        
        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 '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 'ProductID' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public int ProductID
        {
            get
            {
                return this._productID;
            }
            set
            {
                if ((this._productID != value))
                {
                    this.OnProductIDChanging(value);
                    this.ValidateProperty("ProductID", value);
                    this._productID = value;
                    this.RaisePropertyChanged("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();
                }
            }
        }
        
        /// <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);
        }
    }
}
