Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Designer> Set Entity Name Prefix Automatically from the Schema / Group
 

Pages: 1
Designer
Set Entity Name Prefix Automatically from the Schema / Group
Page:1/1 

  Print all messages in this thread  
Poster Message
bdavis
User



Location:

Joined on:
23-Jan-2019 13:46:45
Posted:
6 posts
# Posted on: 15-Jul-2019 14:57:59.  
Is it possible to have a prefix added automatically to the entity class name based on the Schema / Group it is in?

Example
Schema Name: payments
Table Name: tbl_Batch

Generated Entity Class Name: Payments_BatchEntity ??

I'm not currently seeing any quick way of doing this in the designer / project settings, besides manually setting it on the Reverse-Engineer Entity dialog.

Using:
- LLBLGen Pro Framework
- SQL Server
- Designer Version 5.5
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8065 posts
# Posted on: 16-Jul-2019 08:25:52.  
An idea is to use the "Search for elements" feature in the designer (Menu Project -> Search for elements). Then select Enumerable for the element type. Then paste the following in the query area:
Code:
// obtain mapping data
var mappingData = p.MappingData.MappingDataPerDriverID[0];
var mappings = mappingData.EntityMappings;

// used facilitares the camel conversion
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

// process each mapping
var proccessedEntities = new List<string>();
foreach(EntityMapping mapping in mappings)
{
    // find names in the mapping
    var tableName = mapping.MappedTarget.Name;
    var schemaName = mapping.MappedTarget.ContainingSchema.SchemaOwner;
    var newName = textInfo.ToTitleCase(schemaName) + tableName;
    proccessedEntities.Add(newName);
    
    // find the entity and change the name
    EntityDefinition entity = p.EntityModel.Vertices.FirstOrDefault(x => x.Name == mapping.MappedEntity.Name);
    entity.Name = newName;
}

return proccessedEntities;


... if that works, you could convert this into a plugin. You can attach plugin events into designer events (such as add new entity), so the conversion takes place automatically. more info here...


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37455 posts
# Posted on: 16-Jul-2019 10:59:19.  
We'll think about adding this in a future version.
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.