FK Name

Posts   
 
    
kievBug
User
Posts: 105
Joined: 09-Jan-2009
# Posted on: 18-Jan-2011 18:06:00   

Hi guys,

Is there a way to get a FK name if I know entity and relationshipInfo?


    _project = _executingGenerator.ProjectDefinition;
    var entities = _project.GetAllEntities();
    
    foreach(var entity in entities)
    {
        var allRelationshipInfosToTraverse = GeneratorUtils.GetAllRelationshipInfosForEntity(_executingGenerator, entity)
                                                        .Where(ri => ((ri.RelationshipType == EntityRelationshipType.ManyToMany) && ((IndirectRelationshipEdge)ri.Relationship).IsPureManyToMany) ||
                                                                    ((ri.RelationshipType != EntityRelationshipType.ManyToMany) && !ri.NormalRelationship.EntityFkSide.IsPureManyToManyIntermediate))
                                                        .ToList();
        foreach(var relationshipInfo in allRelationshipInfosToTraverse)
        {
                       ///// Here I want to get a constraint name for this relation
        }
    }


Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 19-Jan-2011 09:10:30   

You have the following methods:

relationshipInfo.GetRelationshipFieldPairs() relationshipInfo.GetFkFieldsAsStringFromFkSide()

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 19-Jan-2011 11:54:12   

all FK constraints do have a name in the relational model. Do you want to generate new ones? Could you elaborate a bit what is the purpose of the template ?

Frans Bouma | Lead developer LLBLGen Pro