Generating code
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.
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 4.5.2 code for either Adapter or SelfServicing. If you're more into VB.NET, you should select VB.NET instead of C#.
- 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.
- To open our tutorial project, select it from the Recent Projects list on the Home Tab, or select File -> Open Project... from the main menu, or select the project from the File -> Recent Projects... menu.
-
To generate code, either press
F7
, or select the menu option Project -> Generate Source-code... The Generate Code dialog opens. - As we have just one model in the project, it will show one task, for the Entity Model. As this is the first time we're generating code, it's not currently valid and we have to edit the task. Do this by double-clicking the task or by clicking the Edit Selected Task Specifics button. The Code Generation Task Configuration dialog opens.
- By default the view is the 'Simple' view, with just 1 tab. On this tab, General Settings, select either C# of VB.NET for Target language and select the .NET version of your choice in the ** Target Platform.
- For Root namespace, specify Northwind.Tutorial
- For Template group, either select Adapter, or if you're more into SelfServicing, select SelfServicing.
- 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
- 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, there's just one preset available, SD.Presets.Adapter.General. If you've selected SelfServicing for Template group, you should select SD.Presets.SelfServicing.General from the SelfServicing presets.
- Click OK to close the configuration dialog.
- 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 Perform Tasks... 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 Visual Studio and will do something interesting with it.