Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Designer> Batch rename
 

Pages: 1
Designer
Batch rename
Page:1/1 

  Print all messages in this thread  
Poster Message
jovball
User



Location:
USA
Joined on:
23-Jan-2005 19:53:47
Posted:
393 posts
# Posted on: 09-Jan-2019 21:53:00.  
I have about a dozen wide tables with columns that have the same naming prefix. As an easy example, imagine Customer table with columns named CustomerFirstName, CustomerLastName, CustomerPhone, CustomerEmail, etc.

I would like to remove all of those prefixes without doing "F2 > (edit) > Enter" more than 200 times. Is there any way to do this in the designer? This is for version 5.4.2.
Joel Reinford
LLBLGenPro Version: 5.5.3
Templates: Adapter
Framework: .Net 4.6
Database: SQL Server 2012/2014, DB2 v10
 
Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8080 posts
# Posted on: 10-Jan-2019 05:58:11.  
Hi Joel,

You could write a plugin.

Another way is to use the Element Search. It's commonly used for search objects into the project, but you also can perform actions in such queries. To do that:

1. Open Menu Project -> Search for Elements (Ctrl+F3).
2. In 'Element Type' select 'Enumerable'
3. Write this in the query area:
Code:
var entity = p.EntityModel.Vertices.FirstOrDefault(e=>e.Name=="Customer");
var prefix = entity.Name;

var fields = p.GetAllFieldsForGroupableModelElement(entity);
var newNames = new List<String>();
foreach(var f in fields)
{
    f.Name = f.Name.Replace(prefix, string.Empty);
    newNames.Add(f.Name);        
}

return newNames;

4. Click 'Run Query'. That's it.

Above example would run it for just one entity named 'Customer'. If you want to run on every entity in the project, this would be the query:
Code:
var newNames = new List<String>();
var allEntities = p.EntityModel.Vertices;

foreach(var entity in allEntities)
{
    var prefix = entity.Name;

    var fields = p.GetAllFieldsForGroupableModelElement(entity);    
    foreach(var f in fields)
    {
        f.Name = f.Name.Replace(prefix, string.Empty);
        newNames.Add(entity.Name + "." + f.Name);        
    }
}

return newNames;


Hope that helps Wink


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
jovball
User



Location:
USA
Joined on:
23-Jan-2005 19:53:47
Posted:
393 posts
# Posted on: 10-Jan-2019 16:12:19.  
Yes, that's exactly what I need. For some reason, I completely forgot about element search.
Joel Reinford
LLBLGenPro Version: 5.5.3
Templates: Adapter
Framework: .Net 4.6
Database: SQL Server 2012/2014, DB2 v10
 
Top
Pages: 1  


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

Version: 2.1.12172008 Final.