Adding subtypes to a Typed List

Posts   
 
    
oneness
User
Posts: 21
Joined: 10-Jan-2008
# Posted on: 10-Jan-2011 09:56:00   

Hi

Our configuration details are as follows;

LLBLGen Pro v3 Final RTL version 3.0.10.1210 Adapter .NET 4 SQL 2005

We have a hierarchy as follows; AnnualFinancial <- MonthlyFinancial <- User

Just to clarify, where User is a subtype of MonthlyFinancial, and MonthlyFinancial is a subtype of AnnualFinancial. I am attempting to create a Typed List (EmployeeKeyPerformanceIndicators) in the designer by adding the following entities;

  • EmployeeKeyPerformanceArea
  • EmployeeKeyPerformanceIndicator with a m:1 relationship to EmployeeKeyPerformanceArea

  • User with a 1:m relationship to EmployeeKeyPerformanceArea

I add a number of fields from each of the three entities. However, when I try to fetch the list as follows;

EmployeeKeyPerformanceIndicatorsTypedList toReturn = null;

using (DataAccessAdapter adapter = new DataAccessAdapter())
    {
        EmployeeKeyPerformanceIndicatorsTypedList employeeKeyPerformanceIndicatorsTypedList = new EmployeeKeyPerformanceIndicatorsTypedList();
        adapter.FetchTypedList(employeeKeyPerformanceIndicatorsTypedList);

I receive the following error on the last line above;

"Relation at index 2 doesn't contain an entity already added to the FROM clause. Bad alias?"

As soon as I remove the User table and fields from the Typed List and regen, I can fetch the list without error, but of course I am missing my user fields. I have tried aliasing the User entity when I add it in the designer, both as it's supertype and simply as a completely different name but this doesn't seem to make any difference. Neither does it seem to matter whether I'm trying to use fields that are physically on the User table or on the AnnualFinancial table. I have tried to examine the generated TSQL output in VS but it seems to fail before that is displayed.

I have tried searching for similar existing issues and the closest I could find was http://www.llblgen.com/tinyforum/PrintMessages.aspx?ThreadID=12329 but that seems to indicate that it should be taken care of by now, so I am still a bit lost.

Is there a particular reason I shouldn't be adding a subtype or is there a different way to do it perhaps? Am I missing something?

Any suggestions would be greatly appreciated.

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 10-Jan-2011 15:40:35   

Could you please post a repro (as simple as possible) project file?

oneness
User
Posts: 21
Joined: 10-Jan-2008
# Posted on: 12-Jan-2011 10:38:07   

Hi Walaa

Apologies for the delay. Here you go, simplified project file attached as requested (I removed all but the relevant and related entities and the typed list), I assume you meant a LLBLGenPro project file and not the VS project file?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 12-Jan-2011 17:20:54   

Reproduced.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 12-Jan-2011 17:49:24   

We'll look into this tomorrow morning (thursday CET).

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 13-Jan-2011 12:28:34   

It's indeed a bug in the runtime. It adds the inheritance relationships for User to the relationcollection, however does that from root to leaf (user), which is wrong as it should do this from leaf to root (as leaf is already in the join list).

Working on fix.

(edit) it's a single case where this happens: the relationship isn't the first relationship, the relationship is specified as SubType join SomeEntity, and SomeEntity is already in the join list. Only in that situation this bug occurs, as the hierarchy relations are in the order as if the SubType was the start of the relationship, but it's swapped to be the end, as the SomeEntity is already in the join list. In code you can see this, if you change _filterBucket.Relations.Add( UserEntity.Relations.EmployeeKeyPerformanceAreaEntityUsingUserIdEmployee, "", "", JoinHint.Inner);

to: _filterBucket.Relations.Add( EmployeeKeyPerformanceAreaEntity.Relations.UserEntityUsingUserIdCreated, "", "", JoinHint.Inner);

it will work. Of course, this isn't a good fix, as you generate this code wink but just to show where the issue is located. Stay tuned.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 13-Jan-2011 13:20:40   

Please see the attached dll for the fix.

Frans Bouma | Lead developer LLBLGen Pro
oneness
User
Posts: 21
Joined: 10-Jan-2008
# Posted on: 13-Jan-2011 16:06:33   

Thanks, I will give it a spin and get back to you, much appreciated.

;-)

oneness
User
Posts: 21
Joined: 10-Jan-2008
# Posted on: 14-Jan-2011 13:59:40   

Hi Frans, Walaa

Just wanted to confirm that the fix has done the trick, and to also to say thank you for the really gracious and professional service. It’s such a pleasure dealing with you guys and your company and there are many that could learn a lot from you.

Cheers!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 14-Jan-2011 15:44:20   

Thank you! smile

Frans Bouma | Lead developer LLBLGen Pro