Click here to Skip to main content
15,881,281 members
Articles / Security

N - tier project with WCF OData service, Entity Framework, MVC3.0, Ninject DI, jSOn.net and Automapper

Rate me:
Please Sign up or sign in to vote.
4.62/5 (5 votes)
10 Dec 2012CPOL3 min read 39.4K   1.9K   41  
N-Tier application with WCF Odata service and Entity Framework.
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated from a template.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Runtime.Serialization;

namespace eShopping.Entities.Entities
{
    [DataContract(IsReference = true)]
    [KnownType(typeof(Order))]
    public partial class Customer
    {
        #region Primitive Properties
        [DataMember]
        public virtual string CustomerID
        {
            get;
            set;
        }
        [DataMember]
        public virtual string CompanyName
        {
            get;
            set;
        }
        [DataMember]
        public virtual string ContactName
        {
            get;
            set;
        }
        [DataMember]
        public virtual string ContactTitle
        {
            get;
            set;
        }
        [DataMember]
        public virtual string Address
        {
            get;
            set;
        }
        [DataMember]
        public virtual string City
        {
            get;
            set;
        }
        [DataMember]
        public virtual string Region
        {
            get;
            set;
        }
        [DataMember]
        public virtual string PostalCode
        {
            get;
            set;
        }
        [DataMember]
        public virtual string Country
        {
            get;
            set;
        }
        [DataMember]
        public virtual string Phone
        {
            get;
            set;
        }
        [DataMember]
        public virtual string Fax
        {
            get;
            set;
        }

        #endregion
        #region Navigation Properties
        
    
        [DataMember]
        public virtual ICollection<Order> Orders
        {
            get
            {
                if (_orders == null)
                {
                    var newCollection = new FixupCollection<Order>();
                    newCollection.CollectionChanged += FixupOrders;
                    _orders = newCollection;
                }
                return _orders;
            }
            set
            {
                if (!ReferenceEquals(_orders, value))
                {
                    var previousValue = _orders as FixupCollection<Order>;
                    if (previousValue != null)
                    {
                        previousValue.CollectionChanged -= FixupOrders;
                    }
                    _orders = value;
                    var newValue = value as FixupCollection<Order>;
                    if (newValue != null)
                    {
                        newValue.CollectionChanged += FixupOrders;
                    }
                }
            }
        }
        public ICollection<Order> _orders;

        #endregion
        #region Association Fixup
    
        public void FixupOrders(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.NewItems != null)
            {
                foreach (Order item in e.NewItems)
                {
                    item.Customer = this;
                }
            }
    
            if (e.OldItems != null)
            {
                foreach (Order item in e.OldItems)
                {
                    if (ReferenceEquals(item.Customer, this))
                    {
                        item.Customer = null;
                    }
                }
            }
        }

        #endregion
    }
}

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
Software Developer (Senior) Nagarro Softwares
India India
I am vijay tanwar and i am a software engineer with passion of programming. I love to programming in c#, I love to warp up more and more things in few lines of code. my favirote languages are c# and javascript and both are fully object oriended. I always like to become the .net Architect.

Comments and Discussions