Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Designer> Detailed relation naming/labelling
 

Pages: 1
Designer
Detailed relation naming/labelling
Page:1/1 

  Print all messages in this thread  
Poster Message
JanRHansen
User



Location:

Joined on:
02-Jan-2019 16:48:19
Posted:
3 posts
# Posted on: 11-Feb-2019 12:13:54.  
Hi

I'm in the process of reverse engineering a database / creating documentation for my customer. They need an ER diagram, but would like more information than what is available.

This might be more of a feature request (or several) - or it might just be me not being able to find the correct settings in the designer.

1) Could the relations be displayed with the entity field names as well, and not just the "1" and "Many" labels. Eg. "1 (Id)" and "Many (CustomerId)" at each end of the relation-line.

2) Maybe the relations could snap to the entity next to the actual label, instead of just some arbitrary point on one of the sides.

3) The field datatype, nullable etc. details could be a part of the entity visualization, e.g. "Phone - nvarchar(10)"

I know LLBLGen is not a dedicated database documentation tool, but a little more information would make it just that bit better. I still have to maintain a word document with the tables with descriptions on a business-level, but the diagram would be way better with a bit more details. I hope, that some of the features are actually available Regular Smiley

Using LLBLGen 5.5, MSSQL Server standard 2014.

Best regards
Jan
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14447 posts
# Posted on: 11-Feb-2019 20:41:29.  
I suppose you are talking about the Quick Model Editor, right?

The info is there, if you double click on each relation, but I don't think it will be easily viewable if plotted on the diagram. Usually such diagrams only has the relation type, and usually fieldNames can help convoy the relation.


  Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37317 posts
# Posted on: 13-Feb-2019 13:23:28.  
We tried to add more info to the relationship edges, but it quickly became a big mess, especially with longer names, or with compound PK/FKs. We had to display the names quite small to fit the info which made them unreadable so we opted not to do this.

If you want info about the model you can generate that in whatever output you want however. Regular Smiley E.g. you can generate a HTML file which contains all information about a project, its entities, the mappings etc. using a single template. As docx is xml, you could go overboard and generate the word docx file using a template from the project during code generation.

We ship a template for generating model info to HTML in the templates for NH when you opt for only generating persistence info (and decide to manually write the entity classes for some odd reason): the generated HTML page has the info to properly do that. It could be a start for you to extend on that with the information you need.

Below I'll describe how to do that for an LLBLGen Pro Runtime framework project. I'll assume you're using Adapter, if you're using a different preset, you have to alter that preset. The template is an example of what you can do, you can emit much more data if you want, e.g. mapping info, whatever. The output of the html page gives you a good first indication. (So it's not a drop-in replacement of what you want, but is a start for what you likely need)
(We are aware this procedure is a little complex. We're working on making this easier)

* open in the designer the Preset viewer (Tools -> Preset viewer)
* Select for LLBLGen Pro Runtime Framework the Adapter.general preset
* click 'Copy as new', give it a unique name and click OK
* You'll see the preset as XML, scroll to the bottom, and right above </taskPresets> copy/paste:
Code:

    <taskGroupPreset name="SD.Tasks.Base.GenericTaskGroup" displayName="Generate project info" requiresCleanCache="false">
        <performRule isEnabled="false" settingName="" operator="0" operand="" />
        <taskPreset name="SD.Tasks.Base.ConsumeLptTemplate" displayName="Generate Type info list html page">
            <performRule isEnabled="false" settingName="" operator="0" operand=""/>
            <parameters>
                <parameter name="destinationFolder" value="[driverShortName]\"/>
                <parameter name="filenameFormat" value="ProjectInformation.html"/>
                <parameter name="templateID" value="SD_modelInfoPage"/>
            </parameters>
        </taskPreset>
    </taskGroupPreset>

* In windows explorer, copy the file <llblgen pro installation folder>\Frameworks\NHibernate\Templates\Shared\Shared\typeInfoListPage.lpt to a separate templates folder, e.g. c:\temp\templates (you have to pick this one, I use c:\temp\templates here), and rename it to modelinfopage.lpt
* load your project, and right-click it -> Settings -> General. There for 'Additional templates folder', you specify the folder you copied the lpt template to. Here I specify c:\temp\templates. Click OK.
* open the Template bindings viewer (Tools -> Template Bindings Viewer). Click 'New...' on the right.
* a dialog opens. For name you specify 'Extra bindings'. For templates folder you specify the folder you've specified as additional templates folder'. As filename you specify 'extra.templatebindings'. For frameworks you select 'LLBLGen Pro Runtime Framework'. For platforms and databases you click 'Any'. For target language you select C# (If you're generating VB.NET code, select VB.NET)
* Now add a binding, namely for the ID 'SD_modelInfoPage' (no quotes), and for filename 'modelinfopage.lpt'. For logic language you select 'C#'.
Click 'Save and close'.
The templatebindings viewer should now view the template.
* Double click the template. As it's an nhibernate template you have to replace some code. First append to the bottom the following:

Code:

<~
    internal static string ProduceDotNetTypeName(IFieldElementCore field, IGenerator generator, string nullablePattern)
    {
        string toReturn = string.Empty;
        switch(field.FieldType.KindOfType)
        {
            case FieldTypeKind.DotNetType:
                toReturn = GeneratorUtils.ProduceDotNetTypeName(field.FieldType.RepresentedType, field.IsOptional, nullablePattern);
                toReturn = toReturn.Replace("[", generator.LanguageToUse.ArrayIndexOperatorOpenChar)
                                 .Replace("]", generator.LanguageToUse.ArrayIndexOperatorCloseChar);
                break;                
            case FieldTypeKind.ValueTypeDefinition:
                toReturn = string.Format("{0}.ValueTypeClasses.{1}", generator.RootNamespaceToUse, ((ValueTypeDefinition)field.FieldType).Name);
                break;
        }
        return toReturn;
    }
~>


Then press Ctrl-F and specify with 'Find what': SD_NHibernateGeneralUtils.ProduceDotNetTypeName
specify for Replace with: ProduceDotNetTypeName
Click 'Replace all'.
Press ctrl-shift-s to save the template.
* Click 'Tools -> refresh code generation meta data' to reload the meta data you might have altered. (It might be you have to reload the project as it might not pick up the new templatebindings files. This is a 1 time thing.)

If you now generate code and select as preset the one you created in step 1, you will get an extra file, 'ProjectInformation.html' in the root folder of your generated code. It contains the entity information. This can be extended with mapping info, meta data etc.

Please consult the reference manual for the object model you have at your disposal: https://www.llblgen.com/Documentation/5.5/ReferenceManuals/Designer/html/70919A6F.htm
as well as the SDK docs for template editing: https://www.llblgen.com/Documentation/5.5/SDK/TemplatesandTemplatebindings.htm

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.