This article explains how to create the Domain Model in ASP. NET Web API.
Introduction
This article explains how to create the Domain Model in ASP. NET Web API. A Domain Model identifies the relationship among the entities that are in the scope of the problem domain. It describes the various entities that are attributes, roles and relationships that govern the problem domain.
Now I describe the procedure for creating the Domain Model in the ASP.NET Web API.
First we create the MVC4 Application using the following:
The New ASP.NET MVC 4 Project window is shown. Then:
Now write this code in the "Site.css" file.
Add the class "Material" class. In this class we write this code:
Add the second "Order" class. We write this code in this class:
Add the third class "OrderRecord". We write this code in this class:
Foreign Key relations
There are many order records but each order record contains a single Material. For representing the relation the "OrderRecord" class has the two fields orderId and MaterialId. There is we define the Foreign key constraints. We create the database and show the relationship among these tables. For representing the relationship use the following procedure.
Configure the media type formatters
It is the object used for serializing the data at the time of writing the Web API the HTTP response body. The formatters support both JSON and XML. These two JSON and XML initialize the object by value. Here two classes "Order" and "OrederRecord" both have the references of the other. The formatters follow the references.
Now we write this code in the "WebApiConfig.cs" file.
Write this code:
Hands on ASP.NET GridView