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

namespace SilverlightDataApp.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.Web.Ria.Data;
    using System.Windows.Ria.Data;
    
    
    public sealed partial class MyDomainContext : DomainContext
    {
        
        #region Query root fields
        private static IQueryable<RegTable> _RegTablesQuery = new RegTable[0].AsQueryable();
        #endregion
        
        /// <summary>
        /// Default constructor.
        /// </summary>
        public MyDomainContext() : 
                base(new HttpDomainClient(new Uri("DataService.axd/SilverlightDataApp-Web-MyDomainService/", System.UriKind.Relative)))
        {
        }
        
        /// <summary>
        /// Constructor used to specify a data service URI.
        /// </summary>
        /// <param name="serviceUri">
        /// The MyDomainService data service URI.
        /// </param>
        public MyDomainContext(Uri serviceUri) : 
                base(new HttpDomainClient(serviceUri))
        {
        }
        
        /// <summary>
        /// Constructor used to specify a DomainClient instance.
        /// </summary>
        /// <param name="domainClient">
        /// The DomainClient instance the DomainContext should use.
        /// </param>
        public MyDomainContext(DomainClient domainClient) : 
                base(domainClient)
        {
        }
        
        public EntityList<RegTable> RegTables
        {
            get
            {
                return this.Entities.GetEntityList<RegTable>();
            }
        }
        
        #region Query root properties
        public static IQueryable<RegTable> RegTablesQuery
        {
            get
            {
                return _RegTablesQuery;
            }
        }
        #endregion
        
        #region LoadRegTable method overloads
        /// <summary>
        /// Invokes the server-side method 'GetRegTable' and loads the result into <see cref="RegTable"/>.
        /// </summary>
        [LoadMethod(typeof(RegTable))]
        public void LoadRegTable(IQueryable<RegTable> query, MergeOption mergeOption, object userState)
        {
            base.Load("GetRegTable", null, query, mergeOption, userState);
        }
        
        /// <summary>
        /// Invokes the server-side method 'GetRegTable' and loads the result into <see cref="RegTable"/>.
        /// </summary>
        [LoadMethod(typeof(RegTable))]
        public void LoadRegTable()
        {
            this.LoadRegTable(null, MergeOption.KeepCurrentValues, null);
        }
        
        /// <summary>
        /// Invokes the server-side method 'GetRegTable' and loads the result into <see cref="RegTable"/>.
        /// </summary>
        [LoadMethod(typeof(RegTable))]
        public void LoadRegTable(IQueryable<RegTable> query, object userState)
        {
            this.LoadRegTable(query, MergeOption.KeepCurrentValues, userState);
        }
        #endregion
        
        protected override EntityContainer CreateEntityContainer()
        {
            return new MyDomainContextEntityContainer();
        }
        
        internal sealed class MyDomainContextEntityContainer : EntityContainer
        {
            
            public MyDomainContextEntityContainer()
            {
                this.CreateEntityList<RegTable>(EntityListOperations.All);
            }
        }
    }
    
    [DataContract(Namespace="http://schemas.datacontract.org/2004/07/SilverlightDataApp.Web")]
    public sealed partial class RegTable : Entity
    {
        
        private string _eesnimi;
        
        private string _eriala;
        
        private int _id;
        
        private int _kursus;
        
        private string _perenimi;
        
        private int _vanus;
        
        [DataMember()]
        [Required(ErrorMessage="Palun sisesta eesnimi")]
        public string eesnimi
        {
            get
            {
                return this._eesnimi;
            }
            set
            {
                if ((this._eesnimi != value))
                {
                    this.ValidateProperty("eesnimi", value);
                    this.RaiseDataMemberChanging("eesnimi");
                    this._eesnimi = value;
                    this.RaiseDataMemberChanged("eesnimi");
                }
            }
        }
        
        [DataMember()]
        [Required(ErrorMessage="Palun sisesta oma eriala")]
        public string eriala
        {
            get
            {
                return this._eriala;
            }
            set
            {
                if ((this._eriala != value))
                {
                    this.ValidateProperty("eriala", value);
                    this.RaiseDataMemberChanging("eriala");
                    this._eriala = value;
                    this.RaiseDataMemberChanged("eriala");
                }
            }
        }
        
        [Bindable(false)]
        [DataMember()]
        [Key()]
        public int id
        {
            get
            {
                return this._id;
            }
            set
            {
                if ((this._id != value))
                {
                    this.ValidateProperty("id", value);
                    this.RaiseDataMemberChanging("id");
                    this._id = value;
                    this.RaiseDataMemberChanged("id");
                }
            }
        }
        
        [DataMember()]
        [Range(1, 5, ErrorMessage="Kursus peab olema 1 ja 5 vahel")]
        [Required(ErrorMessage="Palun sisesta vaartus")]
        public int kursus
        {
            get
            {
                return this._kursus;
            }
            set
            {
                if ((this._kursus != value))
                {
                    this.ValidateProperty("kursus", value);
                    this.RaiseDataMemberChanging("kursus");
                    this._kursus = value;
                    this.RaiseDataMemberChanged("kursus");
                }
            }
        }
        
        [DataMember()]
        [Required(ErrorMessage="Palun sisesta perekonnanimi")]
        public string perenimi
        {
            get
            {
                return this._perenimi;
            }
            set
            {
                if ((this._perenimi != value))
                {
                    this.ValidateProperty("perenimi", value);
                    this.RaiseDataMemberChanging("perenimi");
                    this._perenimi = value;
                    this.RaiseDataMemberChanged("perenimi");
                }
            }
        }
        
        [DataMember()]
        [Range(18, 99, ErrorMessage="Vanus peab olema 18 ja 99 vahel")]
        [Required(ErrorMessage="Palun sisesta vanus")]
        public int vanus
        {
            get
            {
                return this._vanus;
            }
            set
            {
                if ((this._vanus != value))
                {
                    this.ValidateProperty("vanus", value);
                    this.RaiseDataMemberChanging("vanus");
                    this._vanus = value;
                    this.RaiseDataMemberChanged("vanus");
                }
            }
        }
        
        public override object GetIdentity()
        {
            return this._id;
        }
    }
}
