Tutorial: Generating code.
Preface
In the
previous tutorial, we created an LLBLGen Pro project in the designer, mapped some entities, a typed view and a retrieval stored procedure call. In this tutorial, we'll use that project to create some sourcecode so we can use the mapped elements in our own programs. A similar (more limited) tutorial is also available in a Flash movie format on our website:
Tutorial - Designer: Generate code (opens in new window)
Generating sourcecode
Please follow the following steps to generate sourcecode from the project we've created in the previous tutorial. This tutorial will be for C# and will generate .NET 2.0 code for either Adapter or SelfServicing. If you're more into VB.NET, you should select VB.NET instead of C#. The following tutorials will have sourcecode for VB.NET as well.
- Start the LLBLGen Pro designer. Either use the Programs start menu or double click the LLBLGenPro.exe in the installation folder to start the LLBLGen Pro designer.
- Select File -> Open Project... or press Cntrl-O, or select the project we created in the previous tutorial from the File -> Recent Projects... menu.
- To generate code, simply press F7, or select the menu option Project -> Generate.... The Configure the code generation process dialog opens.
- On the first tab, General Settings, select either C# of VB.NET for Target language and keep the .NET 2.0 selection for Target platform
- For Root namespace, specify Northwind.Tutorial
- For Template group, either select Adapter, or if you're more into SelfServicing, select SelfServicing.
- We'll generate code for all elements in the project so we don't have to create a subset. For Destination root folder under Code file parameters you should specify a folder into which you want to generate the code. For this tutorial we'll use c:\temp\NorthwindTutorial\DAL
- On the second tab, Template bindings, click under Template bindings sorted on precedence: SD.TemplateBindings.SharedTemplates.BackwardsCompatibility.NET20 so it's selected. Then click the Move down button just as many times till the SD.TemplateBindings.SharedTemplates.BackwardsCompatibility.NET20 template bindings are placed below SD.TemplateBindings.SharedTemplates.NET20 as this is a new project so we don't need backwards compatibility.
- On the third tab, we've to select the preset with tasks we've to run to generate the source code. If you've selected Adapter for Template group on the first tab, you'll have the choice from the Adapter presets, and you should select SD.Presets.Adapter.General2005. If you've selected SelfServicing for Template group, you should select from the SelfServicing presets SD.Presets.SelfServicing.TwoClasses2005.
- We're now done setting everything up. LLBLGen Pro will store your settings in the project file after code generation so you don't have to set things up the next time you're generating code. Click Start generator to generate the sourcecode into the Destination root folder.
You'll now have generated code, ready to be used in your own application, which represents the elements you've designed in the designer: the entities, the typed view and the retrieval stored procedure call. In the next tutorial we'll set things up in VS.NET 2005 and will do something interesting with it.