//------------------------------------------------------------------------------
// <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 GridViewDemos
{
    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 GridViewDemos.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 'Alphabetical_list_of_product' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/GridViewDemos.Web")]
    public sealed partial class Alphabetical_list_of_product : Entity
    {
        
        private Nullable<int> _categoryID;
        
        private string _categoryName;
        
        private bool _discontinued;
        
        private int _productID;
        
        private string _productName;
        
        private string _quantityPerUnit;
        
        private Nullable<short> _reorderLevel;
        
        private Nullable<int> _supplierID;
        
        private Nullable<decimal> _unitPrice;
        
        private Nullable<short> _unitsInStock;
        
        private Nullable<short> _unitsOnOrder;
        
        #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 OnCategoryIDChanging(Nullable<int> value);
        partial void OnCategoryIDChanged();
        partial void OnCategoryNameChanging(string value);
        partial void OnCategoryNameChanged();
        partial void OnDiscontinuedChanging(bool value);
        partial void OnDiscontinuedChanged();
        partial void OnProductIDChanging(int value);
        partial void OnProductIDChanged();
        partial void OnProductNameChanging(string value);
        partial void OnProductNameChanged();
        partial void OnQuantityPerUnitChanging(string value);
        partial void OnQuantityPerUnitChanged();
        partial void OnReorderLevelChanging(Nullable<short> value);
        partial void OnReorderLevelChanged();
        partial void OnSupplierIDChanging(Nullable<int> value);
        partial void OnSupplierIDChanged();
        partial void OnUnitPriceChanging(Nullable<decimal> value);
        partial void OnUnitPriceChanged();
        partial void OnUnitsInStockChanging(Nullable<short> value);
        partial void OnUnitsInStockChanged();
        partial void OnUnitsOnOrderChanging(Nullable<short> value);
        partial void OnUnitsOnOrderChanged();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="Alphabetical_list_of_product"/> class.
        /// </summary>
        public Alphabetical_list_of_product()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets or sets the 'CategoryID' value.
        /// </summary>
        [DataMember()]
        public Nullable<int> CategoryID
        {
            get
            {
                return this._categoryID;
            }
            set
            {
                if ((this._categoryID != value))
                {
                    this.OnCategoryIDChanging(value);
                    this.RaiseDataMemberChanging("CategoryID");
                    this.ValidateProperty("CategoryID", value);
                    this._categoryID = value;
                    this.RaiseDataMemberChanged("CategoryID");
                    this.OnCategoryIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'CategoryName' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [Required()]
        [RoundtripOriginal()]
        [StringLength(15)]
        public string CategoryName
        {
            get
            {
                return this._categoryName;
            }
            set
            {
                if ((this._categoryName != value))
                {
                    this.OnCategoryNameChanging(value);
                    this.ValidateProperty("CategoryName", value);
                    this._categoryName = value;
                    this.RaisePropertyChanged("CategoryName");
                    this.OnCategoryNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Discontinued' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public bool Discontinued
        {
            get
            {
                return this._discontinued;
            }
            set
            {
                if ((this._discontinued != value))
                {
                    this.OnDiscontinuedChanging(value);
                    this.ValidateProperty("Discontinued", value);
                    this._discontinued = value;
                    this.RaisePropertyChanged("Discontinued");
                    this.OnDiscontinuedChanged();
                }
            }
        }
        
        /// <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 'ProductName' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [Required()]
        [RoundtripOriginal()]
        [StringLength(40)]
        public string ProductName
        {
            get
            {
                return this._productName;
            }
            set
            {
                if ((this._productName != value))
                {
                    this.OnProductNameChanging(value);
                    this.ValidateProperty("ProductName", value);
                    this._productName = value;
                    this.RaisePropertyChanged("ProductName");
                    this.OnProductNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'QuantityPerUnit' value.
        /// </summary>
        [DataMember()]
        [StringLength(20)]
        public string QuantityPerUnit
        {
            get
            {
                return this._quantityPerUnit;
            }
            set
            {
                if ((this._quantityPerUnit != value))
                {
                    this.OnQuantityPerUnitChanging(value);
                    this.RaiseDataMemberChanging("QuantityPerUnit");
                    this.ValidateProperty("QuantityPerUnit", value);
                    this._quantityPerUnit = value;
                    this.RaiseDataMemberChanged("QuantityPerUnit");
                    this.OnQuantityPerUnitChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ReorderLevel' value.
        /// </summary>
        [DataMember()]
        public Nullable<short> ReorderLevel
        {
            get
            {
                return this._reorderLevel;
            }
            set
            {
                if ((this._reorderLevel != value))
                {
                    this.OnReorderLevelChanging(value);
                    this.RaiseDataMemberChanging("ReorderLevel");
                    this.ValidateProperty("ReorderLevel", value);
                    this._reorderLevel = value;
                    this.RaiseDataMemberChanged("ReorderLevel");
                    this.OnReorderLevelChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'SupplierID' value.
        /// </summary>
        [DataMember()]
        public Nullable<int> SupplierID
        {
            get
            {
                return this._supplierID;
            }
            set
            {
                if ((this._supplierID != value))
                {
                    this.OnSupplierIDChanging(value);
                    this.RaiseDataMemberChanging("SupplierID");
                    this.ValidateProperty("SupplierID", value);
                    this._supplierID = value;
                    this.RaiseDataMemberChanged("SupplierID");
                    this.OnSupplierIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'UnitPrice' value.
        /// </summary>
        [DataMember()]
        public Nullable<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>
        /// Gets or sets the 'UnitsInStock' value.
        /// </summary>
        [DataMember()]
        public Nullable<short> UnitsInStock
        {
            get
            {
                return this._unitsInStock;
            }
            set
            {
                if ((this._unitsInStock != value))
                {
                    this.OnUnitsInStockChanging(value);
                    this.RaiseDataMemberChanging("UnitsInStock");
                    this.ValidateProperty("UnitsInStock", value);
                    this._unitsInStock = value;
                    this.RaiseDataMemberChanged("UnitsInStock");
                    this.OnUnitsInStockChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'UnitsOnOrder' value.
        /// </summary>
        [DataMember()]
        public Nullable<short> UnitsOnOrder
        {
            get
            {
                return this._unitsOnOrder;
            }
            set
            {
                if ((this._unitsOnOrder != value))
                {
                    this.OnUnitsOnOrderChanging(value);
                    this.RaiseDataMemberChanging("UnitsOnOrder");
                    this.ValidateProperty("UnitsOnOrder", value);
                    this._unitsOnOrder = value;
                    this.RaiseDataMemberChanged("UnitsOnOrder");
                    this.OnUnitsOnOrderChanged();
                }
            }
        }
        
        /// <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()
        {
            if (((this._categoryName == null) 
                        || (this._productName == null)))
            {
                return null;
            }
            return EntityKey.Create(this._categoryName, this._discontinued, this._productID, this._productName);
        }
    }
    
    /// <summary>
    /// The domain context corresponding to the 'ProductsDataService' domain service.
    /// </summary>
    public sealed partial class ProductsDataContext : 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="ProductsDataContext"/> class.
        /// </summary>
        public ProductsDataContext() : 
                this(new WebDomainClient<IProductsDataServiceContract>(new Uri("GridViewDemos-Web-ProductsDataService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductsDataContext"/> class with the specified service URI.
        /// </summary>
        /// <param name="serviceUri">The ProductsDataService service URI.</param>
        public ProductsDataContext(Uri serviceUri) : 
                this(new WebDomainClient<IProductsDataServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="ProductsDataContext"/> class with the specified <paramref name="domainClient"/>.
        /// </summary>
        /// <param name="domainClient">The DomainClient instance to use for this domain context.</param>
        public ProductsDataContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the set of <see cref="Alphabetical_list_of_product"/> entities that have been loaded into this <see cref="ProductsDataContext"/> instance.
        /// </summary>
        public EntitySet<Alphabetical_list_of_product> Alphabetical_list_of_products
        {
            get
            {
                return base.EntityContainer.GetEntitySet<Alphabetical_list_of_product>();
            }
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="Alphabetical_list_of_product"/> entities using the 'GetAlphabetical_list_of_products' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="Alphabetical_list_of_product"/> entities.</returns>
        public EntityQuery<Alphabetical_list_of_product> GetAlphabetical_list_of_productsQuery()
        {
            this.ValidateMethod("GetAlphabetical_list_of_productsQuery", null);
            return base.CreateQuery<Alphabetical_list_of_product>("GetAlphabetical_list_of_products", 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 ProductsDataContextEntityContainer();
        }
        
        /// <summary>
        /// Service contract for the 'ProductsDataService' domain service.
        /// </summary>
        [ServiceContract()]
        public interface IProductsDataServiceContract
        {
            
            /// <summary>
            /// Asynchronously invokes the 'GetAlphabetical_list_of_products' 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/ProductsDataService/GetAlphabetical_list_of_productsDomainServ" +
                "iceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/ProductsDataService/GetAlphabetical_list_of_products", ReplyAction="http://tempuri.org/ProductsDataService/GetAlphabetical_list_of_productsResponse")]
            [WebGet()]
            IAsyncResult BeginGetAlphabetical_list_of_products(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetAlphabetical_list_of_products'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetAlphabetical_list_of_products'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetAlphabetical_list_of_products' operation.</returns>
            QueryResult<Alphabetical_list_of_product> EndGetAlphabetical_list_of_products(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/ProductsDataService/SubmitChangesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/ProductsDataService/SubmitChanges", ReplyAction="http://tempuri.org/ProductsDataService/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 ProductsDataContextEntityContainer : EntityContainer
        {
            
            public ProductsDataContextEntityContainer()
            {
                this.CreateEntitySet<Alphabetical_list_of_product>(EntitySetOperations.None);
            }
        }
    }
}
