V3.0 SelfServicing one-sided Navigators

Posts   
 
    
TD
User
Posts: 9
Joined: 17-Jun-2010
# Posted on: 17-Jun-2010 16:48:37   

I'm using .NET 4.0 - SQL Server 2005 - LLBLGen Pro v3.0

In version 2.6 I was able to hide one side of a FK relationship in the designer. In version 3.0, Navigators are used in the designer, which is very clear and easy to work with. However, it seems that if I have a (m:1) relationship and wish to remove the Navigator from only one of the entities, I get the following warning message in the 3.0 designer:

The relationship 'Contact.NotificationLanguage - Language. (m:1)' has one navigator which is empty, which could lead to problems with SelfServicing

These warning messages do not prevent me from generating code using the 3.0 designer. However, once I open the project and attempt to build in VS 2010, I get many errors which all seem to have the same root cause. The Collection and DAO classes define functions with signatures similar to the following:


Public Overloads Function GetMultiManyToOne(countryInstance As IEntity, notificationLanguageInstance As IEntity, methodOfContactInstance As IEntity, Instance As IEntity, Instance As IEntity) As Boolean
    Return GetMultiManyToOne(countryInstance, notificationLanguageInstance, methodOfContactInstance, Instance, Instance, Me.MaxNumberOfItemsToReturn, Me.SortClauses, Nothing, 0, 0)
End Function

The actual error message in VS 2010 is: Parameter already declared with name 'Instance'

The function signature is obviously trying to account for the Navigators that were deleted in one, but not both entities.

What am I missing here?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 17-Jun-2010 17:00:28   

You cleared / removed the FK side or the PK side navigator? (e.g. did you remove Customer.Orders, or Order.Customer ? )

Frans Bouma | Lead developer LLBLGen Pro
TD
User
Posts: 9
Joined: 17-Jun-2010
# Posted on: 17-Jun-2010 17:05:32   

I have two tables: Contacts and Languages. Contacts contains a column, NotificationLaguage_pKey int, which references the primary key of the Languages table. In the resulting Entity class: Contact, I wish to have a reference to the Language Entity. I do not want the Language Entity to contain a Collection of Contacts. Therefore, I removed the Contacts Navigator from the Language Entity, but left the Language Navigator in the Contact Entity.

So, to your question, it seems I've removed Customer.Orders.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 17-Jun-2010 17:16:27   

TD wrote:

I have two tables: Contacts and Languages. Contacts contains a column, NotificationLaguage_pKey int, which references the primary key of the Languages table. In the resulting Entity class: Contact, I wish to have a reference to the Language Entity. I do not want the Language Entity to contain a Collection of Contacts. Therefore, I removed the Contacts Navigator from the Language Entity, but left the Language Navigator in the Contact Entity.

So, to your question, it seems I've removed Customer.Orders.

Indeed.

I'll setup a repro project and see if we can reproduce your problem (both C# and VB.NET)

(edit) C# seems to work OK, testing VB.NET....

Frans Bouma | Lead developer LLBLGen Pro
TD
User
Posts: 9
Joined: 17-Jun-2010
# Posted on: 17-Jun-2010 17:19:41   

Thanks for the quick response. I am relatively stuck until I can resolve this, so I very much look forward to your reply.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 17-Jun-2010 17:26:12   

VB.NET also works. I.o.w.: could you attach the project? (or email us: support AT llblgen DOT com) you can also attach it to a new thread in the helpdesk forum (and refer to this thread))

(I used Customer, Order, Employee, and removed Customer.Orders (pk side)).

(edit) I can reproduce it when I remove the FK side navigator of the relationship: (so order.Customer). This is not recommended, as you then can't have fk syncs. Either way, your project would illustrate it properly

Frans Bouma | Lead developer LLBLGen Pro
TD
User
Posts: 9
Joined: 17-Jun-2010
# Posted on: 17-Jun-2010 17:39:33   

I have sent the project file to your support email address with DB connection info removed. You should see the same error occur many times over. Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 17-Jun-2010 17:41:53   

TD wrote:

I have sent the project file to your support email address with DB connection info removed. You should see the same error occur many times over. Thanks!

While I wait for the project to arrive, check again whether you indeed removed the PK side navigator, as I think you removed the FK side navigator (which causes this problem). You also run into this ONLY if you do this with multiple relationships, so you have removed multiple FK side navigators for m:1 relationships of Contact.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 17-Jun-2010 17:53:54   

The problem is with Contact - Site and Contact - Staff. You removed both side's navigators, so also the FK side. It's not wise to have no navigator on the FK side. This causes the problem in the method you referred to, not the language navigator.

To work around this, define a navigator on the FK side (so for 'Contact') for the relationships I mentioned above.

It's ok to have no navigator on the PK side (although it will hurt lazy loading in some situations), but it's required to have a navigator on the FK side. you have removed many navigators, and also some on the FK side.

This query in Element search in the designer shows which ones: return from r in p.EntityModel.Edges.Where(e=>e.RelationshipType != EntityRelationshipType.ManyToMany).Cast<NormalRelationshipEdge>() where string.IsNullOrEmpty(r.NavigatorFkSide) select r as RelationshipEdge;

For all these relationships, you'll run into problems. We'll alter the template a bit to avoid this error, but it's highly recommended that you fix your project as well by adding a navigator on the fk side. If you don't want to do that, consider whether you need the relationship.

Frans Bouma | Lead developer LLBLGen Pro
TD
User
Posts: 9
Joined: 17-Jun-2010
# Posted on: 18-Jun-2010 01:12:43   

I have done as you suggested and added back missing FK Navigators. That, along with the new Templates you sent have fixed my problem. Thank you!

Note that my 2.6 project was missing FK "Navigators" and generated and compiled just fine, so this may be something you want to look at accommodating for backward compatibility.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 18-Jun-2010 10:46:28   

TD wrote:

I have done as you suggested and added back missing FK Navigators. That, along with the new Templates you sent have fixed my problem. Thank you!

Note that my 2.6 project was missing FK "Navigators" and generated and compiled just fine, so this may be something you want to look at accommodating for backward compatibility.

In v2.6 there were two levels of hiding: the navigator and the relationship. In v3 there's just 1: a missing / empty navigator. This simplified the code a lot in the lazy loading methods, though indeed we emit code which wouldn't be there in v2.6.

In general, navigators shouldn't be removed/empty, and if you really need it, remove the PK side's navigator. Or remove the relationship entirely wink

Frans Bouma | Lead developer LLBLGen Pro