Click here to Skip to main content
15,886,806 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.5K   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))]
    [KnownType(typeof(Product))]
    public partial class Order_Detail
    {
        #region Primitive Properties
        [DataMember]
        public virtual int OrderID
        {
            get { return _orderID; }
            set
            {
                if (_orderID != value)
                {
                    if (Order != null && Order.OrderID != value)
                    {
                        Order = null;
                    }
                    _orderID = value;
                }
            }
        }
        public int _orderID;
        [DataMember]
        public virtual int ProductID
        {
            get { return _productID; }
            set
            {
                if (_productID != value)
                {
                    if (Product != null && Product.ProductID != value)
                    {
                        Product = null;
                    }
                    _productID = value;
                }
            }
        }
        public int _productID;
        [DataMember]
        public virtual decimal UnitPrice
        {
            get;
            set;
        }
        [DataMember]
        public virtual short Quantity
        {
            get;
            set;
        }
        [DataMember]
        public virtual float Discount
        {
            get;
            set;
        }

        #endregion
        #region Navigation Properties
        
    
        [DataMember]
        public virtual Order Order
        {
            get { return _order; }
            set
            {
                if (!ReferenceEquals(_order, value))
                {
                    var previousValue = _order;
                    _order = value;
                    FixupOrder(previousValue);
                }
            }
        }
        public Order _order;
        
    
        [DataMember]
        public virtual Product Product
        {
            get { return _product; }
            set
            {
                if (!ReferenceEquals(_product, value))
                {
                    var previousValue = _product;
                    _product = value;
                    FixupProduct(previousValue);
                }
            }
        }
        public Product _product;

        #endregion
        #region Association Fixup
    
        public void FixupOrder(Order previousValue)
        {
            if (previousValue != null && previousValue.Order_Details.Contains(this))
            {
                previousValue.Order_Details.Remove(this);
            }
    
            if (Order != null)
            {
                if (!Order.Order_Details.Contains(this))
                {
                    Order.Order_Details.Add(this);
                }
                if (OrderID != Order.OrderID)
                {
                    OrderID = Order.OrderID;
                }
            }
        }
    
        public void FixupProduct(Product previousValue)
        {
            if (previousValue != null && previousValue.Order_Details.Contains(this))
            {
                previousValue.Order_Details.Remove(this);
            }
    
            if (Product != null)
            {
                if (!Product.Order_Details.Contains(this))
                {
                    Product.Order_Details.Add(this);
                }
                if (ProductID != Product.ProductID)
                {
                    ProductID = Product.ProductID;
                }
            }
        }

        #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