Does not contain a definition for 'PrefetchPathDepartmentMetricType'

Posts   
 
    
deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 07-Mar-2022 12:51:19   

What are the alternatives for below entities ?

Relations.Add(MetricItemEntity.Relations.ReportRecipientEntityUsingMetricItemId);
Add(MetricItemEntity.PrefetchPathReportRecipients);
Add(MetricTypeEntity.PrefetchPathDepartmentMetricType).
Add(DepartmentMetricTypeEntity.PrefetchPathDepartment).
Add(DepartmentEntity.PrefetchPathStates);
Add(UserEntity.PrefetchPathApprovals);
Add(UserEntity.PrefetchPathDepartments);
Add(UserEntity.PrefetchPathStates);
Add(MetricItemEntity.PrefetchPathMetricBoilerPlate)
Add(MetricBoilerPlateEntity.PrefetchPathMetricSubType)
Add(MetricItemEntity.PrefetchPathMetricBoilerPlate).
Add(MetricBoilerPlateEntity.PrefetchPathMetricSubType).



Otis avatar
Otis
LLBLGen Pro Team
Posts: 38963
Joined: 17-Aug-2003
# Posted on: 07-Mar-2022 14:59:54   

I don't understand the question, please elaborate.

Frans Bouma | Lead developer LLBLGen Pro
deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 07-Mar-2022 16:50:16   

Otis wrote:

I don't understand the question, please elaborate.

For example, when we are using the below code, we are getting the error as

IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.UserEntity);
            prefetchPath.Add(UserEntity.PrefetchPathRoles);

Error CS0117 'UserEntity' does not contain a definition for 'PrefetchPathRoles'

Walaa avatar
Walaa
Support Team
Posts: 14825
Joined: 21-Aug-2005
# Posted on: 07-Mar-2022 21:23:49   

And what makes you think the UserEntity should have PrefetchPathRoles?

deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 08-Mar-2022 04:51:02   

Walaa wrote:

And what makes you think the UserEntity should have PrefetchPathRoles?

We are migrating the LLBLGen code from 1.x to 5.7. After the migration, we are getting the error. so do we have alternatives for this in the latest migration

Otis avatar
Otis
LLBLGen Pro Team
Posts: 38963
Joined: 17-Aug-2003
# Posted on: 08-Mar-2022 10:14:10   

You really need to start reading the documentation. https://www.llblgen.com/Documentation/5.9/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Adapter/gencode_prefetchpaths_adapter.htm

It might be your generated code has properties now like PrefetchPathRoleCollection, did you check? It's simple .net code. What did visual studio say when you typed the . after the entity type?

Frans Bouma | Lead developer LLBLGen Pro
deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 08-Mar-2022 12:05:17   

Otis wrote:

You really need to start reading the documentation. https://www.llblgen.com/Documentation/5.9/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Adapter/gencode_prefetchpaths_adapter.htm

It might be your generated code has properties now like PrefetchPathRoleCollection, did you check? It's simple .net code. What did visual studio say when you typed the . after the entity type?

When we typed . after the entity type, getting the following suggestions

PrefetchPathUserRoles
PrefetchPathUserStates
PrefetchPathUserApprovals
PrefetchPathDepartmentUsers

Otis avatar
Otis
LLBLGen Pro Team
Posts: 38963
Joined: 17-Aug-2003
# Posted on: 08-Mar-2022 21:10:35   

The name after <PrefetchPath> is the navigator mapped onto the relationship. You can see in the designer what name it should be. The navigator name didn't change because you migrated the project, unless the project was recreated from scratch using 5.x. Check what navigator you need to use to fetch the related entity, then specify that PrefetchPathNavigatorName

Frans Bouma | Lead developer LLBLGen Pro
deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 09-Mar-2022 12:28:08   

Otis wrote:

The name after <PrefetchPath> is the navigator mapped onto the relationship. You can see in the designer what name it should be. The navigator name didn't change because you migrated the project, unless the project was recreated from scratch using 5.x. Check what navigator you need to use to fetch the related entity, then specify that PrefetchPathNavigatorName

After the migration , I am not able to see the particular methods on the corresponding entities . For Eg. In the DepartmentEntity , they provide only one prefetch path.

public static IPrefetchPathElement2 PrefetchPathDepartmentUsers { get { return _staticMetaData.GetPrefetchPathElement("DepartmentUsers", CommonEntityBase.CreateEntityCollection<DepartmentUserEntity>()); } }

But in the code we are mapping to a different one, ie.,

 SubPath.Add(DepartmentEntity.PrefetchPathUsers);

So do we need to create a related entity or we can simply remove the line of code. Please provide the solution

Otis avatar
Otis
LLBLGen Pro Team
Posts: 38963
Joined: 17-Aug-2003
# Posted on: 09-Mar-2022 13:02:21   

In the designer in the Department entity, there's a relationship with Users, correct? Or is there a relationship with DepartmentUser and that entity has a relationship with User?

If the former, the navigator is DepartmentUser, but I think 'User' is a M:N relationship and it might be in your project, the project setting "Auto add many to many relationships" under 'Database first development' wasn't enabled. So the designer didn't add m:n relationships.

To do so, enable the setting in the Project settings -> Database first development -> Reverse engineering -> Auto add many to many relationships. This should add the m:n relationships and with that the missing navigators. (It might be the designer version you're using doesn't yet have the feature to auto-add the relationships without syncing again, in that case sync with the database in the designer to get the m:n relationships). then regenerate the code and they should be there.

Frans Bouma | Lead developer LLBLGen Pro
deepunair
User
Posts: 12
Joined: 24-Feb-2022
# Posted on: 09-Mar-2022 16:59:57   

Otis wrote:

In the designer in the Department entity, there's a relationship with Users, correct? Or is there a relationship with DepartmentUser and that entity has a relationship with User?

If the former, the navigator is DepartmentUser, but I think 'User' is a M:N relationship and it might be in your project, the project setting "Auto add many to many relationships" under 'Database first development' wasn't enabled. So the designer didn't add m:n relationships.

To do so, enable the setting in the Project settings -> Database first development -> Reverse engineering -> Auto add many to many relationships. This should add the m:n relationships and with that the missing navigators. (It might be the designer version you're using doesn't yet have the feature to auto-add the relationships without syncing again, in that case sync with the database in the designer to get the m:n relationships). then regenerate the code and they should be there.

I tried to make the report by enabling the settings and able to find the couple of relationships, but still some are missing. What will we do for that case.

PrfetchPath.Add(MetricItemEntity.PrefetchPathReportRecipients);

For the above navigator, not able to find the suitable mapping.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 38963
Joined: 17-Aug-2003
# Posted on: 10-Mar-2022 09:44:22   

I don't have your project, so I don't know what to suggest. Try to compare what is in the v1.x project with what you have now and what's in the database. The entity model isn't some bizarre format, it's an entity model at the ER/Model level so it should be easy to determine which relationships and thus which navigators to use to obtain the data you need to fetch

Frans Bouma | Lead developer LLBLGen Pro