The “Oslo” May CTP has just been released. You can download the latest release of Oslo from the Oslo Dev Center on MSDN. I have been using this new version and want to give a little tour of the new bits. This will be the first of three posts that take you through creating a simple domain model, building a DSL, importing the Model schema and instance data into the Repository and then exploring and customizing the view of the model using “Quadrant”.
For this example we’ll create a very simple domain model using MSchema that will contain information for a fictional company’s employee information. The DSL will take a simple input text that will be parsed and stored as model instance data. Lastly we will display and customize the view of the Employee model in Quadrant.
The posts will be split as follows:
- Part I – Creating the Model with MSchema
- Part II – Building a DSL with MGrammar
- Part III – Viewing the Model in Quadrant
The Module will be called EmployeeInfo and the schema will contain the definition of an entity called Employee. An employee will have Text fields called FirstName, LastName and Number where Number is the fictional employee’s employee number . The schema for Employee looks like this:
id : Integer32 => AutoNumber();
} where identity(id);
Also we include a field call id which is an integer which will contain a number auto generated by “Oslo” that will be used as a unique identity field for each Employee.
Note: In the Oslo May CTP, the use of “=” has been deprecated. Instead “=>” is used in MSchema and MGrammar. You can read more about the May CTP language changes in the Oslo May CTP Release Notes and Shawn Wildermuth’s blog post “M Language Changes Coming in Next CTP”
Now that we have Employee defined, we still need an extent to hold a list of employees. The line below will define and extent called Employees that contains zero or more Employee records:
That’s it, our simple Employee model is done. Below is the full MSchema file for the Employee model. I used Oslo’s Intellipad editor to create the definition and saved it to an M file called EmployeeModel.m. Here is a picture of the Employee model Intellipad:
The final step will be to compile the Employee model. We do this using the Domain Compiler – m.exe that is part of the “Oslo” SDK from the May CTP and pass it the name of our M file – EmployeeModel.m. This will generate a file called EmployeeModel.mx which contains our compiled model. Below is a screenshot of the compilation step:
That’s it for this installment, we now have our compiled Domain Model. In Part II we will create a DSL that converts some easy to understand text into instance data for our Employee Model.