Navigator fields and inheritance

Posts   
 
    
Deividas
User
Posts: 44
Joined: 01-Oct-2010
# Posted on: 02-Nov-2010 19:51:21   

As promised here's another problem I found:

from jointBillService in metaData.JointBillService
select new
{
    jointBillService.Address.FullString,
    jointBillService.ServiceState.Name
}; 

Here JointBillService inherits Service, Address is a field in JointBillService and ServiceState is a field in Service. This query produces an error with message "Relation at index 1 doesn't contain an entity already added to the FROM clause. Bad alias?".

The workaround I use is:

from jointBillService in metaData.JointBillService
join serviceState in metaData.ServiceState on jointBillService.ServiceStateId equals serviceState.Id
select new
{
    jointBillService.Address.FullString,
    serviceState.Name
};

I've attached a solution for reproduction.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 02-Nov-2010 21:04:58   

Thanks for that, we'll take a look.

Matt

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 04-Nov-2010 14:39:51   

reproduced. adventure works, individual is subtype of customer

var q = from i in metaData.Individual
        select new
        {
            i.Contact.LastName,
            i.SalesTerritory.Name
        };

It's problematic, as the relations added to the set of relations for the query require inheritance relations (to form the sub-supertype tree) as well, and it likely goes wrong there. Looking into it.

(edit) the relationships in the collection are: Individual - Contact Customer - SalesTerritory (as salesterritory is inherited from customer by individual, like yours)

This ordering doesn't add 'customer' to the list of elements to join even though it's a supertype of individual, so the 'customer' coming in in relationship 2 fails. You see the effect when you flip the projection:

var q = from i in metaData.Individual
        select new
        {
            i.SalesTerritory.Name,
            i.Contact.LastName
        };

works. Looking into why this is not taking into account supertypes/subtypes in the other situation.

Hopefully it goes smoother than yesterday where we found the cause and spot of the issue around 3PM but fixed it at 7PM as all attempts to change it failed somewhere in a test. simple_smile

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39908
Joined: 17-Aug-2003
# Posted on: 04-Nov-2010 15:22:39   

Fixed in the attached ormsupportclasses.

Frans Bouma | Lead developer LLBLGen Pro