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

A N-Tier Architecture Sample with ASP.NET MVC3, WCF, and Entity Framework

Rate me:
Please Sign up or sign in to vote.
4.85/5 (91 votes)
11 Sep 2012CPOL48 min read 554.7K   31.7K   425  
This article tries to introduce a decoupled, unit-testable, deployment-flexible, implementation-efficient and validation-flexible N-Tier architecture in .NET
using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Data.Services.Client;
using System.Linq;
using System.Text;
using GH.Common.Utils;
using GH.Common.Framework.Persistence.DataServiceContext;
using GH.Northwind.Common.Entities;
using GH.Common.Framework.Persistence; 


namespace GH.ProductRegistration.Persistence.DataServiceContext
{
    public class ProductRegPrst : PersistenceBase<Customer>
    {
        override protected IQueryable<Customer> EntitySet
        { get { return null; /* return (DataContext as HelperOnly.ds.GHProductRegEntities).Customers; */} }

        override protected String EntitySetName
        { get { return _entitySetName ?? (_entitySetName = Util.GetMemberNameExtra((HelperOnly.ds.GHProductRegEntities g) => g.Customers)); } }
    }

    public class ProductPrst : PersistenceBase<Product>
    {
        override protected IQueryable<Product> EntitySet
        { get { return null; /*return (DataContext as HelperOnly.ds.GHProductRegEntities).Productes;*/ } }

        override protected String EntitySetName
        { get { return _entitySetName ?? (_entitySetName = Util.GetMemberNameExtra((HelperOnly.ds.GHProductRegEntities g) => g.Productes)); } }
    }

    public class OrderPrst : PersistenceBase<Order>
    {
        override protected IQueryable<Order> EntitySet
        { get { return null; /*return (DataContext as HelperOnly.ds.GHProductRegEntities).Orders;*/ } }

        override protected String EntitySetName
        { get { return _entitySetName ?? (_entitySetName = Util.GetMemberNameExtra((HelperOnly.ds.GHProductRegEntities g) => g.Orders)); } }
    }

    public class Order_DetailPrst : PersistenceBase<Order_Detail>
    {
        override protected IQueryable<Order_Detail> EntitySet
        { get { return null; /*return (DataContext as HelperOnly.ds.GHProductRegEntities).Order_Detailes; */} }

        override protected String EntitySetName
        { get { return _entitySetName ?? (_entitySetName = Util.GetMemberNameExtra((HelperOnly.ds.GHProductRegEntities g) => g.Order_Detailes)); } }
    }
}



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
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions