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.
The framework can also be downloaded from CodePlex: http://nlayers.codeplex.com/.
What is NLayers?
NLayers has the following:
- Visual Studio 2010 solution template for layered applications
- Contains Data Access wrapper class for CRUD operations
Following is the snapshot of a solution created using the NLayers template:
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/
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.
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.
On creating the project template, we will see the Solution Explorer as given below.
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.
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.
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.)
Projects in NLayers
On creating a new Project from the NLayers ASP.NET Application template, you can see the Solution Explorer as shown below:
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:
Layers in NLayers
The layers inside the NLayers architecture are as follows:
- Web Application representing the Presentation Layer
- Business Logic representing the Business Logic Layer
- Data Access representing the Data Access Layer
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.