Archive for April, 2009

Building the ASP.NET MVC Application

In the last 2 posts we have seen how to develop the Repository and WCF Services for our sample ASP.NET MVC application.This application contains the following Views:

  • Home/Index (Index.aspx) – Displaying the list of Bookmarks with options to Add New,Edit and Delete.
  • Add New (Create.aspx) – Displaying a blank form to enter the URL and Description.
  • Edit (Edit.aspx) – Displaying URL and Description of the selected bookmark.Only Description is editable.

There is a controller BookmarkController for all the above mentioned views.
(more…)

Advertisements

Building the Service

In my last post I have explained step by step how we can implement the Repository pattern with ADO.NET Entity Framework.In this post we will see how to expose that functionality as a WCF service.But prior to that let us briefly touch upon the Service Interface pattern to get our concepts clear.While developing enterprise application most of the times we try to decouple the Business Logic components from the UI components so that the two can evolve and change independently of each other.Along with this the ability to scale out the application across multiple nodes is also another driver.This pattern addresses these forces and provides a solution where we expose our business functionality via a Web Service which can be accessed by multiple clients over the network using varied protocols.

Now we will see step by step how to develop the WCF based Service Interface for our Bookmark Repository.

(more…)

Building The Repository

In my last post I had discussed about the various O/R mapping patterns and Repository is one of them.In this post we will develop a repository library for our sample application.This application is a very list of personal bookmarks with an url and description.

Step1: Create the database table

The database contains a single table called Bookmarks as shown below:

CREATE TABLE [dbo].[Bookmarks](
    [BookmarkId] [int] IDENTITY(1,1) NOT NULL,
    [Url] [varchar](100) COLLATE Latin1_General_CI_AI NOT NULL,
    [Description] [text] COLLATE Latin1_General_CI_AI NOT NULL,
CONSTRAINT [PK_Bookmarks] PRIMARY KEY CLUSTERED
(
    [BookmarkId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

(more…)

Normally while developing ASP.NET applications we follow a layered architecture with the Web/Presentation layer decoupled from the core business logic via the Service Interface.Whereas most of the examples we come across in ASP.NET MVC, the Model (O/R layer) seems to be very tightly integrated with the web application.I just started how I can seperate out the O/R layer and expose it via a WCF service and make the ASP.NET MVC application talk to the this service only.While doing so I found out that to seperate the different components into individual layer it is extremely important to understand the underlying application design patterns, how and where they fit in.In this post I will discuss about the Object Relational Mapping patterns and how it can help us to isolate the O/R.The three object relational mapping patterns discussed in this post are from Martin Fowler’s Patterns of Enterprise Application Architecture.
(more…)