Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Introduction to NLayers

4.33/5 (3 votes)
9 May 2012CPOL3 min read 13.4K  
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)