Click here to Skip to main content
15,892,809 members
Articles / Programming Languages / XML

Efficiently exposing your data with minimal effort

Rate me:
Please Sign up or sign in to vote.
4.88/5 (19 votes)
16 Nov 2009CPOL14 min read 50K   386   30  
An article on how we can expose our data efficiently with minimal effort by leveraging Microsoft ADO.NET Data Services.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3074
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("EmployeeModel", "FK_tblCompDtls_tblEmp", "tblEmp", global::System.Data.Metadata.Edm.RelationshipMultiplicity.One, typeof(DataServicesDemo.tblEmp), "tblCompDtls", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(DataServicesDemo.tblCompDtls))]

// Original file name:
// Generation date: 11/5/2009 11:34:27 AM
namespace DataServicesDemo
{
    
    /// <summary>
    /// There are no comments for EmployeeEntity in the schema.
    /// </summary>
    public partial class EmployeeEntity : global::System.Data.Objects.ObjectContext
    {
        /// <summary>
        /// Initializes a new EmployeeEntity object using the connection string found in the 'EmployeeEntity' section of the application configuration file.
        /// </summary>
        public EmployeeEntity() : 
                base("name=EmployeeEntity", "EmployeeEntity")
        {
            this.OnContextCreated();
        }
        /// <summary>
        /// Initialize a new EmployeeEntity object.
        /// </summary>
        public EmployeeEntity(string connectionString) : 
                base(connectionString, "EmployeeEntity")
        {
            this.OnContextCreated();
        }
        /// <summary>
        /// Initialize a new EmployeeEntity object.
        /// </summary>
        public EmployeeEntity(global::System.Data.EntityClient.EntityConnection connection) : 
                base(connection, "EmployeeEntity")
        {
            this.OnContextCreated();
        }
        partial void OnContextCreated();
        /// <summary>
        /// There are no comments for tblCompDtls in the schema.
        /// </summary>
        public global::System.Data.Objects.ObjectQuery<tblCompDtls> tblCompDtls
        {
            get
            {
                if ((this._tblCompDtls == null))
                {
                    this._tblCompDtls = base.CreateQuery<tblCompDtls>("[tblCompDtls]");
                }
                return this._tblCompDtls;
            }
        }
        private global::System.Data.Objects.ObjectQuery<tblCompDtls> _tblCompDtls;
        /// <summary>
        /// There are no comments for tblEmp in the schema.
        /// </summary>
        public global::System.Data.Objects.ObjectQuery<tblEmp> tblEmp
        {
            get
            {
                if ((this._tblEmp == null))
                {
                    this._tblEmp = base.CreateQuery<tblEmp>("[tblEmp]");
                }
                return this._tblEmp;
            }
        }
        private global::System.Data.Objects.ObjectQuery<tblEmp> _tblEmp;
        /// <summary>
        /// There are no comments for tblCompDtls in the schema.
        /// </summary>
        public void AddTotblCompDtls(tblCompDtls tblCompDtls)
        {
            base.AddObject("tblCompDtls", tblCompDtls);
        }
        /// <summary>
        /// There are no comments for tblEmp in the schema.
        /// </summary>
        public void AddTotblEmp(tblEmp tblEmp)
        {
            base.AddObject("tblEmp", tblEmp);
        }
    }
    /// <summary>
    /// There are no comments for EmployeeModel.tblCompDtls in the schema.
    /// </summary>
    /// <KeyProperties>
    /// EmpId
    /// </KeyProperties>
    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="EmployeeModel", Name="tblCompDtls")]
    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    [global::System.Serializable()]
    public partial class tblCompDtls : global::System.Data.Objects.DataClasses.EntityObject
    {
        /// <summary>
        /// Create a new tblCompDtls object.
        /// </summary>
        /// <param name="empId">Initial value of EmpId.</param>
        public static tblCompDtls CreatetblCompDtls(short empId)
        {
            tblCompDtls tblCompDtls = new tblCompDtls();
            tblCompDtls.EmpId = empId;
            return tblCompDtls;
        }
        /// <summary>
        /// There are no comments for Property EmpId in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public short EmpId
        {
            get
            {
                return this._EmpId;
            }
            set
            {
                this.OnEmpIdChanging(value);
                this.ReportPropertyChanging("EmpId");
                this._EmpId = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("EmpId");
                this.OnEmpIdChanged();
            }
        }
        private short _EmpId;
        partial void OnEmpIdChanging(short value);
        partial void OnEmpIdChanged();
        /// <summary>
        /// There are no comments for Property Grade in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string Grade
        {
            get
            {
                return this._Grade;
            }
            set
            {
                this.OnGradeChanging(value);
                this.ReportPropertyChanging("Grade");
                this._Grade = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("Grade");
                this.OnGradeChanged();
            }
        }
        private string _Grade;
        partial void OnGradeChanging(string value);
        partial void OnGradeChanged();
        /// <summary>
        /// There are no comments for Property Level in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string Level
        {
            get
            {
                return this._Level;
            }
            set
            {
                this.OnLevelChanging(value);
                this.ReportPropertyChanging("Level");
                this._Level = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("Level");
                this.OnLevelChanged();
            }
        }
        private string _Level;
        partial void OnLevelChanging(string value);
        partial void OnLevelChanged();
        /// <summary>
        /// There are no comments for Property Salary in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Nullable<decimal> Salary
        {
            get
            {
                return this._Salary;
            }
            set
            {
                this.OnSalaryChanging(value);
                this.ReportPropertyChanging("Salary");
                this._Salary = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("Salary");
                this.OnSalaryChanged();
            }
        }
        private global::System.Nullable<decimal> _Salary;
        partial void OnSalaryChanging(global::System.Nullable<decimal> value);
        partial void OnSalaryChanged();
        /// <summary>
        /// There are no comments for Property Stocks in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Nullable<int> Stocks
        {
            get
            {
                return this._Stocks;
            }
            set
            {
                this.OnStocksChanging(value);
                this.ReportPropertyChanging("Stocks");
                this._Stocks = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("Stocks");
                this.OnStocksChanged();
            }
        }
        private global::System.Nullable<int> _Stocks;
        partial void OnStocksChanging(global::System.Nullable<int> value);
        partial void OnStocksChanged();
        /// <summary>
        /// There are no comments for tblEmp in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("EmployeeModel", "FK_tblCompDtls_tblEmp", "tblEmp")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public tblEmp tblEmp
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<tblEmp>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblEmp").Value;
            }
            set
            {
                ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<tblEmp>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblEmp").Value = value;
            }
        }
        /// <summary>
        /// There are no comments for tblEmp in the schema.
        /// </summary>
        [global::System.ComponentModel.BrowsableAttribute(false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityReference<tblEmp> tblEmpReference
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<tblEmp>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblEmp");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<tblEmp>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblEmp", value);
                }
            }
        }
    }
    /// <summary>
    /// There are no comments for EmployeeModel.tblEmp in the schema.
    /// </summary>
    /// <KeyProperties>
    /// EmpID
    /// </KeyProperties>
    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="EmployeeModel", Name="tblEmp")]
    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    [global::System.Serializable()]
    public partial class tblEmp : global::System.Data.Objects.DataClasses.EntityObject
    {
        /// <summary>
        /// Create a new tblEmp object.
        /// </summary>
        /// <param name="empID">Initial value of EmpID.</param>
        public static tblEmp CreatetblEmp(short empID)
        {
            tblEmp tblEmp = new tblEmp();
            tblEmp.EmpID = empID;
            return tblEmp;
        }
        /// <summary>
        /// There are no comments for Property EmpID in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public short EmpID
        {
            get
            {
                return this._EmpID;
            }
            set
            {
                this.OnEmpIDChanging(value);
                this.ReportPropertyChanging("EmpID");
                this._EmpID = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("EmpID");
                this.OnEmpIDChanged();
            }
        }
        private short _EmpID;
        partial void OnEmpIDChanging(short value);
        partial void OnEmpIDChanged();
        /// <summary>
        /// There are no comments for Property FirstName in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string FirstName
        {
            get
            {
                return this._FirstName;
            }
            set
            {
                this.OnFirstNameChanging(value);
                this.ReportPropertyChanging("FirstName");
                this._FirstName = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("FirstName");
                this.OnFirstNameChanged();
            }
        }
        private string _FirstName;
        partial void OnFirstNameChanging(string value);
        partial void OnFirstNameChanged();
        /// <summary>
        /// There are no comments for Property LastName in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string LastName
        {
            get
            {
                return this._LastName;
            }
            set
            {
                this.OnLastNameChanging(value);
                this.ReportPropertyChanging("LastName");
                this._LastName = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("LastName");
                this.OnLastNameChanged();
            }
        }
        private string _LastName;
        partial void OnLastNameChanging(string value);
        partial void OnLastNameChanged();
        /// <summary>
        /// There are no comments for Property Age in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Nullable<short> Age
        {
            get
            {
                return this._Age;
            }
            set
            {
                this.OnAgeChanging(value);
                this.ReportPropertyChanging("Age");
                this._Age = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("Age");
                this.OnAgeChanged();
            }
        }
        private global::System.Nullable<short> _Age;
        partial void OnAgeChanging(global::System.Nullable<short> value);
        partial void OnAgeChanged();
        /// <summary>
        /// There are no comments for Property Sex in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string Sex
        {
            get
            {
                return this._Sex;
            }
            set
            {
                this.OnSexChanging(value);
                this.ReportPropertyChanging("Sex");
                this._Sex = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("Sex");
                this.OnSexChanged();
            }
        }
        private string _Sex;
        partial void OnSexChanging(string value);
        partial void OnSexChanged();
        /// <summary>
        /// There are no comments for Property City in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string City
        {
            get
            {
                return this._City;
            }
            set
            {
                this.OnCityChanging(value);
                this.ReportPropertyChanging("City");
                this._City = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("City");
                this.OnCityChanged();
            }
        }
        private string _City;
        partial void OnCityChanging(string value);
        partial void OnCityChanged();
        /// <summary>
        /// There are no comments for Property Country in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string Country
        {
            get
            {
                return this._Country;
            }
            set
            {
                this.OnCountryChanging(value);
                this.ReportPropertyChanging("Country");
                this._Country = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("Country");
                this.OnCountryChanged();
            }
        }
        private string _Country;
        partial void OnCountryChanging(string value);
        partial void OnCountryChanged();
        /// <summary>
        /// There are no comments for tblCompDtls in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("EmployeeModel", "FK_tblCompDtls_tblEmp", "tblCompDtls")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public tblCompDtls tblCompDtls
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<tblCompDtls>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblCompDtls").Value;
            }
            set
            {
                ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<tblCompDtls>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblCompDtls").Value = value;
            }
        }
        /// <summary>
        /// There are no comments for tblCompDtls in the schema.
        /// </summary>
        [global::System.ComponentModel.BrowsableAttribute(false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityReference<tblCompDtls> tblCompDtlsReference
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<tblCompDtls>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblCompDtls");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<tblCompDtls>("EmployeeModel.FK_tblCompDtls_tblEmp", "tblCompDtls", value);
                }
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect Collabera
India India
Gnana (Gnanasekaran) is currently working as a Senior Architect at Collabera, Bangalore, India, having more than 10 years experience. His area of specialization includes SOA, BPM, Messaging, Integration and Enterprise Architecture. The emerging tech. trends like web 2.0 and Enterprise Mobility excites him a lot. Architectural consulting is his core expertise. He also possess experience in Data warehousing and business intelligence solutions consulting, based on the Microsoft technology stack like SSAS, SSIS and SQL Server. You can reach him via e-mails at gnana.sekaran@collabera.com & vgnanasekaran@yahoo.com or at www.gnanasekaran.com

Comments and Discussions