//------------------------------------------------------------------------------
// <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 RadGridViewCrash
{
    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 RadGridViewCrash.Web.Models
{
    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 'CompanySearchResult' entity class.
    /// </summary>
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/RadGridViewCrash.Web.Models")]
    public sealed partial class CompanySearchResult : Entity
    {
        
        private string _address;
        
        private int _childCompanies;
        
        private int[] _childCompanyIDs;
        
        private string _city;
        
        private int _companyID;
        
        private string _companyName;
        
        private string _country;
        
        private Nullable<int> _parentCompanyID;
        
        private string _zipCode;
        
        #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 OnChildCompaniesChanging(int value);
        partial void OnChildCompaniesChanged();
        partial void OnChildCompanyIDsChanging(int[] value);
        partial void OnChildCompanyIDsChanged();
        partial void OnCityChanging(string value);
        partial void OnCityChanged();
        partial void OnCompanyIDChanging(int value);
        partial void OnCompanyIDChanged();
        partial void OnCompanyNameChanging(string value);
        partial void OnCompanyNameChanged();
        partial void OnCountryChanging(string value);
        partial void OnCountryChanged();
        partial void OnParentCompanyIDChanging(Nullable<int> value);
        partial void OnParentCompanyIDChanged();
        partial void OnZipCodeChanging(string value);
        partial void OnZipCodeChanged();

        #endregion
        
        
        /// <summary>
        /// Initializes a new instance of the <see cref="CompanySearchResult"/> class.
        /// </summary>
        public CompanySearchResult()
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets or sets the 'Address' value.
        /// </summary>
        [DataMember()]
        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 'ChildCompanies' value.
        /// </summary>
        [DataMember()]
        public int ChildCompanies
        {
            get
            {
                return this._childCompanies;
            }
            set
            {
                if ((this._childCompanies != value))
                {
                    this.OnChildCompaniesChanging(value);
                    this.RaiseDataMemberChanging("ChildCompanies");
                    this.ValidateProperty("ChildCompanies", value);
                    this._childCompanies = value;
                    this.RaiseDataMemberChanged("ChildCompanies");
                    this.OnChildCompaniesChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ChildCompanyIDs' value.
        /// </summary>
        [DataMember()]
        public int[] ChildCompanyIDs
        {
            get
            {
                return this._childCompanyIDs;
            }
            set
            {
                if ((this._childCompanyIDs != value))
                {
                    this.OnChildCompanyIDsChanging(value);
                    this.RaiseDataMemberChanging("ChildCompanyIDs");
                    this.ValidateProperty("ChildCompanyIDs", value);
                    this._childCompanyIDs = value;
                    this.RaiseDataMemberChanged("ChildCompanyIDs");
                    this.OnChildCompanyIDsChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'City' value.
        /// </summary>
        [DataMember()]
        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 'CompanyID' value.
        /// </summary>
        [DataMember()]
        [Editable(false, AllowInitialValue=true)]
        [Key()]
        [RoundtripOriginal()]
        public int CompanyID
        {
            get
            {
                return this._companyID;
            }
            set
            {
                if ((this._companyID != value))
                {
                    this.OnCompanyIDChanging(value);
                    this.ValidateProperty("CompanyID", value);
                    this._companyID = value;
                    this.RaisePropertyChanged("CompanyID");
                    this.OnCompanyIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'CompanyName' value.
        /// </summary>
        [DataMember()]
        public string CompanyName
        {
            get
            {
                return this._companyName;
            }
            set
            {
                if ((this._companyName != value))
                {
                    this.OnCompanyNameChanging(value);
                    this.RaiseDataMemberChanging("CompanyName");
                    this.ValidateProperty("CompanyName", value);
                    this._companyName = value;
                    this.RaiseDataMemberChanged("CompanyName");
                    this.OnCompanyNameChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'Country' value.
        /// </summary>
        [DataMember()]
        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 'ParentCompanyID' value.
        /// </summary>
        [DataMember()]
        public Nullable<int> ParentCompanyID
        {
            get
            {
                return this._parentCompanyID;
            }
            set
            {
                if ((this._parentCompanyID != value))
                {
                    this.OnParentCompanyIDChanging(value);
                    this.RaiseDataMemberChanging("ParentCompanyID");
                    this.ValidateProperty("ParentCompanyID", value);
                    this._parentCompanyID = value;
                    this.RaiseDataMemberChanged("ParentCompanyID");
                    this.OnParentCompanyIDChanged();
                }
            }
        }
        
        /// <summary>
        /// Gets or sets the 'ZipCode' value.
        /// </summary>
        [DataMember()]
        public string ZipCode
        {
            get
            {
                return this._zipCode;
            }
            set
            {
                if ((this._zipCode != value))
                {
                    this.OnZipCodeChanging(value);
                    this.RaiseDataMemberChanging("ZipCode");
                    this.ValidateProperty("ZipCode", value);
                    this._zipCode = value;
                    this.RaiseDataMemberChanged("ZipCode");
                    this.OnZipCodeChanged();
                }
            }
        }
        
        /// <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._companyID;
        }
    }
    
    /// <summary>
    /// The domain context corresponding to the 'TestDomainService' domain service.
    /// </summary>
    public sealed partial class TestDomainContext : 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="TestDomainContext"/> class.
        /// </summary>
        public TestDomainContext() : 
                this(new WebDomainClient<ITestDomainServiceContract>(new Uri("RadGridViewCrash-Web-Models-TestDomainService.svc", UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="TestDomainContext"/> class with the specified service URI.
        /// </summary>
        /// <param name="serviceUri">The TestDomainService service URI.</param>
        public TestDomainContext(Uri serviceUri) : 
                this(new WebDomainClient<ITestDomainServiceContract>(serviceUri))
        {
        }
        
        /// <summary>
        /// Initializes a new instance of the <see cref="TestDomainContext"/> class with the specified <paramref name="domainClient"/>.
        /// </summary>
        /// <param name="domainClient">The DomainClient instance to use for this domain context.</param>
        public TestDomainContext(DomainClient domainClient) : 
                base(domainClient)
        {
            this.OnCreated();
        }
        
        /// <summary>
        /// Gets the set of <see cref="CompanySearchResult"/> entities that have been loaded into this <see cref="TestDomainContext"/> instance.
        /// </summary>
        public EntitySet<CompanySearchResult> CompanySearchResults
        {
            get
            {
                return base.EntityContainer.GetEntitySet<CompanySearchResult>();
            }
        }
        
        /// <summary>
        /// Gets an EntityQuery instance that can be used to load <see cref="CompanySearchResult"/> entities using the 'GetEntity_CompanySearchResult' query.
        /// </summary>
        /// <returns>An EntityQuery that can be loaded to retrieve <see cref="CompanySearchResult"/> entities.</returns>
        public EntityQuery<CompanySearchResult> GetEntity_CompanySearchResultQuery()
        {
            this.ValidateMethod("GetEntity_CompanySearchResultQuery", null);
            return base.CreateQuery<CompanySearchResult>("GetEntity_CompanySearchResult", 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 TestDomainContextEntityContainer();
        }
        
        /// <summary>
        /// Service contract for the 'TestDomainService' domain service.
        /// </summary>
        [ServiceContract()]
        public interface ITestDomainServiceContract
        {
            
            /// <summary>
            /// Asynchronously invokes the 'GetEntity_CompanySearchResult' 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/TestDomainService/GetEntity_CompanySearchResultDomainServiceFa" +
                "ult", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/TestDomainService/GetEntity_CompanySearchResult", ReplyAction="http://tempuri.org/TestDomainService/GetEntity_CompanySearchResultResponse")]
            [WebGet()]
            IAsyncResult BeginGetEntity_CompanySearchResult(AsyncCallback callback, object asyncState);
            
            /// <summary>
            /// Completes the asynchronous operation begun by 'BeginGetEntity_CompanySearchResult'.
            /// </summary>
            /// <param name="result">The IAsyncResult returned from 'BeginGetEntity_CompanySearchResult'.</param>
            /// <returns>The 'QueryResult' returned from the 'GetEntity_CompanySearchResult' operation.</returns>
            QueryResult<CompanySearchResult> EndGetEntity_CompanySearchResult(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/TestDomainService/SubmitChangesDomainServiceFault", Name="DomainServiceFault", Namespace="DomainServices")]
            [OperationContract(AsyncPattern=true, Action="http://tempuri.org/TestDomainService/SubmitChanges", ReplyAction="http://tempuri.org/TestDomainService/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 TestDomainContextEntityContainer : EntityContainer
        {
            
            public TestDomainContextEntityContainer()
            {
                this.CreateEntitySet<CompanySearchResult>(EntitySetOperations.None);
            }
        }
    }
}
