Click here to Skip to main content
15,884,176 members
Articles / Programming Languages / C#

Introduction to NLayers

Rate me:
Please Sign up or sign in to vote.
4.33/5 (3 votes)
9 May 2012CPOL3 min read 13.1K   14   2
This article explains the installation and usage of the NLayers framework.

Introduction

In this article I would like to introduce a layering framework named NLayers. This article is intended for experienced developers or architects with a good understanding of ASP.NET and the ADO.NET Entity Framework.

img1.gif

The framework can also be downloaded from CodePlex: http://nlayers.codeplex.com/.

What is NLayers?

NLayers has the following:

  1. Visual Studio 2010 solution template for layered applications
  2. Contains Data Access wrapper class for CRUD operations

Following is the snapshot of a solution created using the NLayers template:

img5.gif

The core methods inside the DataAccess base class include the following:

  • Insert()
  • Update()
  • Delete()
  • GetAll()
  • Where()

The layered application framework can be used to create the following types of projects:

  • ASP.NET Web Application
  • WCF Service Application
  • Windows/WPF Application

Installation

Please download the latest setup file from the URL: http://nlayers.codeplex.com/

img2.gif

Use the Download button on the right side to get the NLayers.msi file.

Execute the MSI file, choose the installation folder, and click "Next" to complete the wizard. There will be a series of command lines executed for copying the templates and running the installation commands.

img3.gif

After the installation, open Visual Studio to view the NLayers installation.

Inside Visual Studio: Adding Solution

Inside Visual Studio, use File -> New Project to get the dialog box. You can see the NLayers ASP.NETApplication template from the NLayers group as shown below.

img4.gif

On creating the project template, we will see the Solution Explorer as given below.

img5.gif

Please make NLayers1.Web as the startup project if it is not.

Inside Visual Studio: Adding Items

For adding items, use the Add Item dialog from the respective project.

img6.gif

For example

NLayers Business Logic class should be added to the NLayers.BusinessLogic project. NLayers Data Access class should be added to the NLayers.DataAccess.Implementation project. NLayers Data Access Interface should be added to the NLayers.DataAccess.Interface project.

Documentation

Apart from this article, you can get the official documentation of NLayers from: http://nlayers.codeplex.com/documentation.

img7.gif

Using NLayers

You can create an NLayers solution using the template as shown below. (You need to install the NLayers framework to see the below template.)

Image 9

Projects in NLayers

On creating a new Project from the NLayers ASP.NET Application template, you can see the Solution Explorer as shown below:

Image 10

Project Description

NLayers.BusinessLogic

Business Logic part of the solution. Least expected to be changing the implementation classes throughout the lifetime of the project.

NLayers.DataAccess.Interface

Decoupled design for Data Access.

NLayers.DataAccess.Implementation

Implementation of Data Access Interface project.

NLayers.Entity

Project containing the EDMX file of Entity Framework. It contains the entity classes.

NLayers.InstanceManager

Project providing instance management for Business Logic and Data Access classes.

NLayers.Web

ASP.NET Web Application. This project uses the WebApp class of InstanceManager to access Business Logic and Data Access instances.

Control Flow

The startup project should be NLayers.Web. The web project will use the Instance Manager project to invoke Business Logic and Data Access classes. The entity project will be used by all projects. The following diagram depicts the control flow:

Image 11

Layers in NLayers

The layers inside the NLayers architecture are as follows:

  1. Web Application representing the Presentation Layer
  2. Business Logic representing the Business Logic Layer
  3. Data Access representing the Data Access Layer

Image 12

NLayers Advantages

Following are the advantages of NLayers over a typical monolithic application:

  • Decoupled design  / Separation of concerns
  • Easier manageability
  • Better support for Unit Testing
  • Easier replacement of Data Access implementation
  • Instance management
  • CRUD wrappers over Entity Framework
  • VS 2010 Project and Item Templates for Quick Start
  • Better support for Dependency Injection / Policy Injection

Source

This article is meant to provide information on the NLayers project. You can access the latest source or documentation from: http://nlayers.codeplex.com/documentation.

Summary

This article explains the installation and usage of the NLayers framework.

License

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


Written By
Architect
United States United States
Jean Paul is a Microsoft MVP and Architect with 12+ years of experience. He is very much passionate in programming and his core skills are SharePoint, ASP.NET & C#.

In the academic side he do hold a BS in Computer Science & MBA. In the certification side he holds MCPD & MCTS spanning from .Net Fundamentals to SQL Server.

Most of the free time he will be doing technical activities like researching solutions, writing articles, resolving forum problems etc. He believes quality & satisfaction goes hand in hand.

You can find some of his work over here. He blogs at http://jeanpaulva.com

Comments and Discussions

 
QuestionInteresting, but... Pin
Dewey9-May-12 12:38
Dewey9-May-12 12:38 
AnswerRe: Interesting, but... Pin
FernandoUY5-Jul-12 8:19
professionalFernandoUY5-Jul-12 8:19 
This is a great response. Constructive and having in count the effort.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.