Change CollectionNavigatorType for a specific navigation

Posts   
 
    
mrpmorris
User
Posts: 26
Joined: 07-Jul-2017
# Posted on: 20-Dec-2017 16:51:15   

On this page, there is a setting named "CollectionNavigatorType" https://www.llblgen.com/Documentation/5.3/Entity%20Framework/VCore2/AvailableOutputSettings.htm

Where in the designer can I change that value for a specific navigator? I want the type of just one of these to be different.

My code-gen reads as follows, so this is where I need to detect the value I set in the designer.

    var relationshipInitializersBuilder = new StringBuilder();
    foreach(var relationshipInfo in allRelationshipInfosToTraverse)
    {
        if(relationshipInfo.NavigatorIsHidden)
        {
            continue;
        }
        switch(relationshipInfo.RelationshipType)
        {
            case EntityRelationshipType.OneToMany:
                var collectionType = "List";
                var settingValue = relationshipInfo.NavigatorInstance.OutputSettingValues.GetRealStringSettingValue("CollectionNavigatorType", currentProject);
                switch(settingValue)
                {
                    case "List<T>":
                        collectionType = "List";
                        break;
                    case "ICollection<T>":
                        collectionType = "HashSet";
                        break;
                    case "IEnumerable<T>":
                        // no instantiation, continue.
                        continue;
                }
                relationshipInitializersBuilder.AppendLine(
                    "           this." + 
                    relationshipInfo.Navigator + 
                    " = new " + collectionType + "<" + relationshipInfo.RelatedEntity.Name + ">();"
                );
                break;
        }
    }   
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 21-Dec-2017 00:33:50   

It's there on the Project Settings (Conventions/EntityModel/Entity Framework Core v.2), if you have selected EF Core v.2 as the Framework to use for the LLBLGen project.

mrpmorris
User
Posts: 26
Joined: 07-Jul-2017
# Posted on: 21-Dec-2017 10:17:29   

Walaa wrote:

It's there on the Project Settings (Conventions/EntityModel/Entity Framework Core v.2), if you have selected EF Core v.2 as the Framework to use for the LLBLGen project.

You've misunderstood. That sets the default, I want to change it for an individual relationship.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 21-Dec-2017 11:07:41   

Open the entity the navigator is part of, go to 'Code generation info' tab then settings, and select the navigator to change the value. You can also use the Bulk Element settings manipulator tool from the Tools menu to set these kind of settings for multiple elements in 1 go (otherwise it would be a LOT of clicking wink )

Frans Bouma | Lead developer LLBLGen Pro
mrpmorris
User
Posts: 26
Joined: 07-Jul-2017
# Posted on: 21-Dec-2017 11:15:19   

Otis wrote:

Open the entity the navigator is part of

Right-clicked my parent entity, and selected the Edit option.

Otis wrote:

go to 'Code generation info' tab

Clicked Code generation info tab at the bottom of the UI that appeared.

Otis wrote:

then settings,

I don't see anything labelled "settings" in the UI. (Version 5.3.1)

https://imgur.com/a/tHPuy

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 21-Dec-2017 15:15:14   

Sorry, 'Setting values' (I did it from memory, should have opened the designer and looked flushed ). there in 'element' you select the navigator, and the settings for that navigator are then shown, initialized with the default values from the project defaults. You can then override them there.

Frans Bouma | Lead developer LLBLGen Pro
mrpmorris
User
Posts: 26
Joined: 07-Jul-2017
# Posted on: 21-Dec-2017 15:18:39   

Otis wrote:

Sorry, 'Setting values' (I did it from memory, should have opened the designer and looked flushed ). there in 'element' you select the navigator, and the settings for that navigator are then shown, initialized with the default values from the project defaults. You can then override them there.

I'm still struggling to follow your instructions. Is there any chance you could do a screencap for me to follow (Windows Key + G is good for recording an app).

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39613
Joined: 17-Aug-2003
# Posted on: 21-Dec-2017 15:57:50   

In the screenshot you added, you're already on the Setting values tab, the entity is currently selected in the Element selector (where you placed the black square, the setting values tab and other tabs are directly below the black square simple_smile ). There where the black square is in your screenshot, select the navigator, and the settings grid below it will fill with the settings for that navigator simple_smile

Frans Bouma | Lead developer LLBLGen Pro
mrpmorris
User
Posts: 26
Joined: 07-Jul-2017
# Posted on: 21-Dec-2017 15:59:26   

Otis wrote:

In the screenshot you added, you're already on the Setting values tab, the entity is currently selected in the Element selector (where you placed the black square, the setting values tab and other tabs are directly below the black square simple_smile ). There where the black square is in your screenshot, select the navigator, and the settings grid below it will fill with the settings for that navigator simple_smile

Ohhh! When you said to select the navigator, I was selecting it in the tree view simple_smile

Thanks!