Through this article, I am going to show you how to use Sculpture to create and manage your applications. We will begin by building Entities and a Data Access Layer by using LINQ, and a Service Layer by using WCF, Then, we will generate the same model with an NHibernate + ASMX web service.
The first thing you need to do is set up your projects.
As discussed before, the Sculpture Core Engine does nothing alone, you must plug it with your favorite Molds; we will begin by adding these Molds:
Each one of these Molds contains:
To add Molds to your model, press the ‘Molds Manager’ button in the Sculpture Details Window, then add your Molds by choosing ‘.mold’ files. (You will find the ready-made Molds in the Sculpture installed directory.) The Molds Manager looks like the following figure, save the model. Unfortunately, you must restart your Visual Studio so the Molds can take effect.
After restarting Visual Studio, right click on the model surface and press ‘Details’. You will notice that some buttons and editors have appeared in the Sculpture details window.
The first thing we need to do in the model is specify the project responsibilities; this tells Sculpture where the code will be generated, and sets the values as in the next figure. (In this sample, we generate the data contracts, translators, fault contracts, service contracts, and service implementation in one project; but in a real application, you might specify a project for each one).
It’s time to produce deployable components from our model. As we mentioned earlier, we start with the LINQ Mold for the data access layer and the WCF Mold for the service layer.
The generation process is so simple, just right click on the diagram surface, and click ‘Generate’. Sculpture will generate the code and attach it to the corresponding project. After generation, the Solution Explorer must be like in the next figure:
Let’s explore the generated code quickly:
Before testing the application, we need to add the missing references and add our custom code:
public partial class CategoriesService
public override Categories GetById(int categoryid)
It’s time to test our project, set the WCF Service project as the startup project and run the application.
As we mentioned before, one of the major advantages of the Model Driven Development approach is raising the level of abstraction, so your problem is not related to its implementation technology. In this section, I will show you how you can switch your implementation technology from LINQ and WCF to NHibernate and ASMX web services.
Model-Driven Development represents the next logical step in software development methods and practices. It aims at facilitating the automatic construction of a software solution from a high-level domain-specific specification. This approach seeks to promote productivity, maintainability, expressiveness, and to aid in the management of complexity by supporting higher levels of abstraction and the systematic reuse of domain-specific assets. (From: Model-Driven Development of .NET Enterprise Applications). Sculpture (Model your Life) is a new implementation in this track, which you can use for modeling business entities, data contracts, and services. Based on this model, Sculpture transports it to your favorite technology. Sculpture is a pluggable engine so you can plug your custom code generator.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
Peter Hayward wrote:USA guys
Ahmed Negm wrote:We are not USA guys
General News Suggestion Question Bug Answer Joke Praise Rant Admin
Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.