Upload
gregdorian2009
View
214
Download
1
Embed Size (px)
Citation preview
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 1/10
This walkthrough will get you started with the Inertia: Business Entity ComponentGenerator that is available in Layered Architecture Solution Guidance 2013[http://visualstudiogallery.msdn.microsoft.com/caa8f808d4a54f48a88eda572834f37e] .The first step in creating layered applications after designing the database is tocreate the entity classes. Before beginning this guide, please make sure that youhave completed the previous tutorial on Getting Started with LASG [http://serenayeoh.blogspot.com/2014/02/lasggettingstarted.html] .
This walkthrough also uses the LeaveSample database that is part of the LayeredArchitecture Sample for .NET [http://layersample.codeplex.com/] but you may use yourown database to follow through.
[./HowTo Create Entities with Inertia in LASG Firedancer Unleashed!_files/01Guide.png]
1. In Solution Explorer, expand the Tutorial solution, go to the Shared folder, rightclick on the Tutorial.Entities project and click Add Entities...
How-To: Create Entities with Inertia in LASG
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 2/10
[./HowTo Create Entities with Inertia in LASG Firedancer Unleashed!_files/01Launch.png]
2. The Inertia: Business Entity Component Generator will launch. The codegenerator is divided into 3 sections.
[./HowTo Create Entities with Inertia in LASG Firedancer Unleashed!_files/01Inertia.png]
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 3/10
Tip: Notice the code generator is colour coded to the code generation guide.
3. At the 1. Choose Data Source and Columns section, click the Connect buttonto connect to a Microsoft SQL Server.
4. In the Connect... dialog, enter the Server name and select the appropriateauthentication method. Click Connect to connect to the SQL server.
[./HowTo Create Entities withInertia in LASG Firedancer Unleashed!_files/01Connection.png]
Note: LASG uses the SQL Server Management Objects and therefore, onlyMicrosoft SQL Server is supported. You can use any editions of SQL Serverincluding the Express edition.
5. Select the LeaveSample database from the database list located beside theConnect button.
6. In the Source tab, select the Leaves table from the Sources dropdown list. All itscolumns will be listed in the list box below the Columns check box.
Tip: Inertia will attempt to suggest the entity class name for you based on theselected table’s name. If your tables have plural names, the Singularize classnames option will attempt to suggest singular entity class names for you.
7. If you are not using the LeaveSample database tables and have abbreviatedcolumn names i.e. hr_wkflowID, PrdName, StdMercName etc., you can createmeaningful property names for them by clicking on the bar above the column list.This launches the Define Column Mappings dialog. Make any necessarychanges to the Property Name and click OK when done.
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 4/10
[./HowTo CreateEntities with Inertia in LASG Firedancer Unleashed!_files/01DefineMap.png]
Note: It is recommended that you have well defined meaningful column namesin the tables than to rely on the column mappings.
8. Check on the Columns check box to select all the columns and click on the [./HowTo Create Entities with Inertia in LASG Firedancer Unleashed!_files/01RightButton.png] button to add them to the 2. Define Entity Settings section.
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 5/10
[./HowTo Create Entities with Inertia in LASG Firedancer Unleashed!_files/01Selected.png]
Tip: You can also individually select or deselect columns. Press the Ctrl keywhile clicking on the columns to select/deselect individual columns or use theShift key to select/deselect a range of adjacent columns.
Note: Not all datatypes are supported. Complex datatypes are currently notsupported.
9. The Reference To tab will show all the tables that the current table is referencingto with a foreign key. You can choose to relate to the entire table as a referenceobject or individually select the columns which you want to include as part of thecurrent entity (a.k.a. borrowed columns). Once you are done with yourselections, click on the [./HowTo Create Entities with Inertia in LASG FiredancerUnleashed!_files/01RightButton.png] button to add them to the Entityproperties grid. For simplicity, we shall not add anything from here in this tutorial.
10. The Reference By tab shows all the tables that is referencing the current tablewith a foreign key. You can choose to relate the tables here as a collection ofEntities. Click on the [./HowTo Create Entities with Inertia in LASG FiredancerUnleashed!_files/01RightButton.png] button to add them to the Entityproperties grid. You will also need to generate the Entity classes individually forthe tables you selected here later. For simplicity, we shall not add anything fromhere in this tutorial.
11. The columns that you choose will appear in the Entity properties grid under the 2. Define Entity Settings section as properties to be generated for the Entity.You can make adjustments here i.e. changing the comments or marking a
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 6/10
property to accept nulls.
Tip: In case you want to remove any columns from the properties list, just selectthe row and press the Delete key on the keyboard or your can rightclick on theselected row to invoke a context menu to delete it.
12. Once you are ready, click on the Add to Code Generation button to queue thedefinition to the 3. Generate Entities section. You can queue as many entitiesfor code generation as you wish. To create another entity, simply click on theNew button. For this tutorial, we shall create 2 entities Leave andLeaveStatusLog.
13. Each queued entity definition will be listed in the 3. Generate Entities section.You can review the definitions and make any last moment changes in theproperty grid located at the bottom of the section. You can delete any entityproperties by selecting the row and pressing the Delete key.
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 7/10
[./HowTo Create Entities withInertia in LASG Firedancer Unleashed!_files/01Generate.png]
Caution! Tampering with the properties in the property grid may causeunexpected results or errors in code generation. Make sure you understandthe behaviour of the code generator before messing with the values in theproperty grid.
14. You can perform various action from the toolbar at the 3. Generate Entities section. You can Preview the code that will be generated, set Options, repositionthe properties, Reset the definitions so that they will be codegenerated again orDelete the definitions.
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 8/10
[./HowTo Create Entitieswith Inertia in LASG Firedancer Unleashed!_files/01Toolbar.png]
Warning! Deleted definitions will not be recoverable.
Note: All definitions will be marked as code generated (indicated by theIsUpdated property) after code generation. They will continue to appear in thelist but will not be code generated the next time. Clicking Reset will change oneor more definitions' IsUpdated value to true and mark them for code generationagain.
You can also Delete an entity property, an entity definition or all entity definitionsfrom the toolbar. Clicking on the Options icon will open the Code GenerationOptions dialog that will allow you to set a few standard options. Leave thesettings alone and click OK.
[./HowTo Create Entities with Inertia inLASG Firedancer Unleashed!_files/01Options.png]
15. Finally, click the Generate button to generate the entity classes.
16. At the Code Generation Completed dialog, click OK.
17. The Tutorial.Entities project should contain the generated code files for theentities.
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 9/10
[./HowTo Create Entitieswith Inertia in LASG Firedancer Unleashed!_files/01Project.png]
Summary
We have basically gone through how to use the Inertia: Business Entity ComponentGenerator to create Entity classes for our layered application. You can make anynecessary changes to the code but take note that any changes made in your codewill not be reflected in the definitions stored in Inertia. Therefore, practice cautionwhen you are regenerating code on existing code file.
Coming up next HowTo: Create Data Access Components with Momentum inLASG [http://serenayeoh.blogspot.com/2014/03/lasgcreatingdataaccesscomponents.html].
Posted 5th March by Serena Yeoh
Labels: .NET, 3tier, C#, Developer Community, LASG, Layered Architecture
Sign out
Notify me
Enter your comment...
Comment as: greg_dorian (Google)
Publish
Preview
0 Add a comment
15/10/2015 HowTo: Create Entities with Inertia in LASG | Firedancer Unleashed!
file:///C:/Users/greg/Desktop/layered/HowTo%20%20Create%20Entities%20with%20Inertia%20in%20LASG%20%20%20Firedancer%20Unleashed!.html 10/10