Click here to Skip to main content
15,896,371 members
Articles / Web Development / ASP.NET

Custom JSON Serializer for the Entity Framework

Rate me:
Please Sign up or sign in to vote.
4.82/5 (13 votes)
29 Apr 2009CPOL1 min read 53.5K   678   38  
Custom JSON serializer for the Entity Framework
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:2.0.50727.3053
//
//     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("ErpDBModel", "FK_Tasks_Categories", "Categories", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(TestConsole.Categories), "Tasks", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(TestConsole.Tasks))]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("ErpDBModel", "FK_Tasks_Users", "Users", global::System.Data.Metadata.Edm.RelationshipMultiplicity.ZeroOrOne, typeof(TestConsole.Users), "Tasks", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(TestConsole.Tasks))]

// Original file name:
// Generation date: 4/28/2009 11:27:11 PM
namespace TestConsole
{
    
    /// <summary>
    /// There are no comments for ErpDBEntities2 in the schema.
    /// </summary>
    public partial class ErpDBEntities2 : global::System.Data.Objects.ObjectContext
    {
        /// <summary>
        /// Initializes a new ErpDBEntities2 object using the connection string found in the 'ErpDBEntities2' section of the application configuration file.
        /// </summary>
        public ErpDBEntities2() : 
                base("name=ErpDBEntities2", "ErpDBEntities2")
        {
            this.OnContextCreated();
        }
        /// <summary>
        /// Initialize a new ErpDBEntities2 object.
        /// </summary>
        public ErpDBEntities2(string connectionString) : 
                base(connectionString, "ErpDBEntities2")
        {
            this.OnContextCreated();
        }
        /// <summary>
        /// Initialize a new ErpDBEntities2 object.
        /// </summary>
        public ErpDBEntities2(global::System.Data.EntityClient.EntityConnection connection) : 
                base(connection, "ErpDBEntities2")
        {
            this.OnContextCreated();
        }
        partial void OnContextCreated();
        /// <summary>
        /// There are no comments for Categories in the schema.
        /// </summary>
        public global::System.Data.Objects.ObjectQuery<Categories> Categories
        {
            get
            {
                if ((this._Categories == null))
                {
                    this._Categories = base.CreateQuery<Categories>("[Categories]");
                }
                return this._Categories;
            }
        }
        private global::System.Data.Objects.ObjectQuery<Categories> _Categories;
        /// <summary>
        /// There are no comments for Tasks in the schema.
        /// </summary>
        public global::System.Data.Objects.ObjectQuery<Tasks> Tasks
        {
            get
            {
                if ((this._Tasks == null))
                {
                    this._Tasks = base.CreateQuery<Tasks>("[Tasks]");
                }
                return this._Tasks;
            }
        }
        private global::System.Data.Objects.ObjectQuery<Tasks> _Tasks;
        /// <summary>
        /// There are no comments for Users in the schema.
        /// </summary>
        public global::System.Data.Objects.ObjectQuery<Users> Users
        {
            get
            {
                if ((this._Users == null))
                {
                    this._Users = base.CreateQuery<Users>("[Users]");
                }
                return this._Users;
            }
        }
        private global::System.Data.Objects.ObjectQuery<Users> _Users;
        /// <summary>
        /// There are no comments for Categories in the schema.
        /// </summary>
        public void AddToCategories(Categories categories)
        {
            base.AddObject("Categories", categories);
        }
        /// <summary>
        /// There are no comments for Tasks in the schema.
        /// </summary>
        public void AddToTasks(Tasks tasks)
        {
            base.AddObject("Tasks", tasks);
        }
        /// <summary>
        /// There are no comments for Users in the schema.
        /// </summary>
        public void AddToUsers(Users users)
        {
            base.AddObject("Users", users);
        }
    }
    /// <summary>
    /// There are no comments for ErpDBModel.Categories in the schema.
    /// </summary>
    /// <KeyProperties>
    /// CategoryID
    /// </KeyProperties>
    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="ErpDBModel", Name="Categories")]
    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    [global::System.Serializable()]
    public partial class Categories : global::System.Data.Objects.DataClasses.EntityObject
    {
        /// <summary>
        /// Create a new Categories object.
        /// </summary>
        /// <param name="categoryID">Initial value of CategoryID.</param>
        public static Categories CreateCategories(int categoryID)
        {
            Categories categories = new Categories();
            categories.CategoryID = categoryID;
            return categories;
        }
        /// <summary>
        /// There are no comments for Property CategoryID in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public int CategoryID
        {
            get
            {
                return this._CategoryID;
            }
            set
            {
                this.OnCategoryIDChanging(value);
                this.ReportPropertyChanging("CategoryID");
                this._CategoryID = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("CategoryID");
                this.OnCategoryIDChanged();
            }
        }
        private int _CategoryID;
        partial void OnCategoryIDChanging(int value);
        partial void OnCategoryIDChanged();
        /// <summary>
        /// There are no comments for Property CategoryName in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string CategoryName
        {
            get
            {
                return this._CategoryName;
            }
            set
            {
                this.OnCategoryNameChanging(value);
                this.ReportPropertyChanging("CategoryName");
                this._CategoryName = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("CategoryName");
                this.OnCategoryNameChanged();
            }
        }
        private string _CategoryName;
        partial void OnCategoryNameChanging(string value);
        partial void OnCategoryNameChanged();
        /// <summary>
        /// There are no comments for Tasks in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("ErpDBModel", "FK_Tasks_Categories", "Tasks")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityCollection<Tasks> Tasks
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Tasks>("ErpDBModel.FK_Tasks_Categories", "Tasks");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Tasks>("ErpDBModel.FK_Tasks_Categories", "Tasks", value);
                }
            }
        }
    }
    /// <summary>
    /// There are no comments for ErpDBModel.Tasks in the schema.
    /// </summary>
    /// <KeyProperties>
    /// TaskID
    /// </KeyProperties>
    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="ErpDBModel", Name="Tasks")]
    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    [global::System.Serializable()]
    public partial class Tasks : global::System.Data.Objects.DataClasses.EntityObject
    {
        /// <summary>
        /// Create a new Tasks object.
        /// </summary>
        /// <param name="taskID">Initial value of TaskID.</param>
        /// <param name="createdDate">Initial value of CreatedDate.</param>
        public static Tasks CreateTasks(string taskID, global::System.DateTime createdDate)
        {
            Tasks tasks = new Tasks();
            tasks.TaskID = taskID;
            tasks.CreatedDate = createdDate;
            return tasks;
        }
        /// <summary>
        /// There are no comments for Property TaskID in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string TaskID
        {
            get
            {
                return this._TaskID;
            }
            set
            {
                this.OnTaskIDChanging(value);
                this.ReportPropertyChanging("TaskID");
                this._TaskID = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, false);
                this.ReportPropertyChanged("TaskID");
                this.OnTaskIDChanged();
            }
        }
        private string _TaskID;
        partial void OnTaskIDChanging(string value);
        partial void OnTaskIDChanged();
        /// <summary>
        /// There are no comments for Property TaskDescription in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string TaskDescription
        {
            get
            {
                return this._TaskDescription;
            }
            set
            {
                this.OnTaskDescriptionChanging(value);
                this.ReportPropertyChanging("TaskDescription");
                this._TaskDescription = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("TaskDescription");
                this.OnTaskDescriptionChanged();
            }
        }
        private string _TaskDescription;
        partial void OnTaskDescriptionChanging(string value);
        partial void OnTaskDescriptionChanged();
        /// <summary>
        /// There are no comments for Property CreatedDate in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.DateTime CreatedDate
        {
            get
            {
                return this._CreatedDate;
            }
            set
            {
                this.OnCreatedDateChanging(value);
                this.ReportPropertyChanging("CreatedDate");
                this._CreatedDate = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("CreatedDate");
                this.OnCreatedDateChanged();
            }
        }
        private global::System.DateTime _CreatedDate;
        partial void OnCreatedDateChanging(global::System.DateTime value);
        partial void OnCreatedDateChanged();
        /// <summary>
        /// There are no comments for Categories in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("ErpDBModel", "FK_Tasks_Categories", "Categories")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public Categories Categories
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Categories>("ErpDBModel.FK_Tasks_Categories", "Categories").Value;
            }
            set
            {
                ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Categories>("ErpDBModel.FK_Tasks_Categories", "Categories").Value = value;
            }
        }
        /// <summary>
        /// There are no comments for Categories in the schema.
        /// </summary>
        [global::System.ComponentModel.BrowsableAttribute(false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityReference<Categories> CategoriesReference
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Categories>("ErpDBModel.FK_Tasks_Categories", "Categories");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Categories>("ErpDBModel.FK_Tasks_Categories", "Categories", value);
                }
            }
        }
        /// <summary>
        /// There are no comments for Users in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("ErpDBModel", "FK_Tasks_Users", "Users")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public Users Users
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Users>("ErpDBModel.FK_Tasks_Users", "Users").Value;
            }
            set
            {
                ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Users>("ErpDBModel.FK_Tasks_Users", "Users").Value = value;
            }
        }
        /// <summary>
        /// There are no comments for Users in the schema.
        /// </summary>
        [global::System.ComponentModel.BrowsableAttribute(false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityReference<Users> UsersReference
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedReference<Users>("ErpDBModel.FK_Tasks_Users", "Users");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedReference<Users>("ErpDBModel.FK_Tasks_Users", "Users", value);
                }
            }
        }
    }
    /// <summary>
    /// There are no comments for ErpDBModel.Users in the schema.
    /// </summary>
    /// <KeyProperties>
    /// UserID
    /// </KeyProperties>
    [global::System.Data.Objects.DataClasses.EdmEntityTypeAttribute(NamespaceName="ErpDBModel", Name="Users")]
    [global::System.Runtime.Serialization.DataContractAttribute(IsReference=true)]
    [global::System.Serializable()]
    public partial class Users : global::System.Data.Objects.DataClasses.EntityObject
    {
        /// <summary>
        /// Create a new Users object.
        /// </summary>
        /// <param name="userID">Initial value of UserID.</param>
        public static Users CreateUsers(int userID)
        {
            Users users = new Users();
            users.UserID = userID;
            return users;
        }
        /// <summary>
        /// There are no comments for Property UserID in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public int UserID
        {
            get
            {
                return this._UserID;
            }
            set
            {
                this.OnUserIDChanging(value);
                this.ReportPropertyChanging("UserID");
                this._UserID = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value);
                this.ReportPropertyChanged("UserID");
                this.OnUserIDChanged();
            }
        }
        private int _UserID;
        partial void OnUserIDChanging(int value);
        partial void OnUserIDChanged();
        /// <summary>
        /// There are no comments for Property UserName in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public string UserName
        {
            get
            {
                return this._UserName;
            }
            set
            {
                this.OnUserNameChanging(value);
                this.ReportPropertyChanging("UserName");
                this._UserName = global::System.Data.Objects.DataClasses.StructuralObject.SetValidValue(value, true);
                this.ReportPropertyChanged("UserName");
                this.OnUserNameChanged();
            }
        }
        private string _UserName;
        partial void OnUserNameChanging(string value);
        partial void OnUserNameChanged();
        /// <summary>
        /// There are no comments for Tasks in the schema.
        /// </summary>
        [global::System.Data.Objects.DataClasses.EdmRelationshipNavigationPropertyAttribute("ErpDBModel", "FK_Tasks_Users", "Tasks")]
        [global::System.Xml.Serialization.XmlIgnoreAttribute()]
        [global::System.Xml.Serialization.SoapIgnoreAttribute()]
        [global::System.Runtime.Serialization.DataMemberAttribute()]
        public global::System.Data.Objects.DataClasses.EntityCollection<Tasks> Tasks
        {
            get
            {
                return ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.GetRelatedCollection<Tasks>("ErpDBModel.FK_Tasks_Users", "Tasks");
            }
            set
            {
                if ((value != null))
                {
                    ((global::System.Data.Objects.DataClasses.IEntityWithRelationships)(this)).RelationshipManager.InitializeRelatedCollection<Tasks>("ErpDBModel.FK_Tasks_Users", "Tasks", 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
Bangladesh Bangladesh
How do I describe myself to you? How can I explain that this is true?
I am who I am because of you! My work I love you !!

Comments and Discussions