CorrelatedOver using inheritance when not required

Posts   
 
    
simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 07-Feb-2018 20:23:06   
            var query = qf.ClassGroup
                .Select(
                    ClassGroupFields.ID,
                    ClassGroupFields.Name,
                    ClassGroupFields.YearGroup,
                    ClassGroupFields.TeacherID,
                    ClassGroupFields.Teacher2ID,
                    ClassGroupFields.AssistantID,
                    ClassGroupFields.Assistant2ID,
                    ClassGroupFields.Email,
                    ClassGroupFields.IsFinesActive,
                    [b]qf.User[/b].CorrelatedOver(UserFields.ClassGroupID == ClassGroupFields.ID).CountRow().As(CountFieldName)
                );

This is the query I want to run but the SQL generated uses "Borrower" rather than the "User" highlighted in bold). Borrower is a sub-type of User but the relation to ClassGroup is on User. I also tried the CorrelatedOver overload that takes a relationship but get the same problem.

I have used this type of CorrelatedOver construct before without any problem..

            var query = qf.Keyword
                .OrderBy(KeywordFields.Phrase | SortOperator.Ascending)
                .Select(
                    KeywordFields.ID,
                    KeywordFields.Phrase,
                    qf.ResourceToKeyword.CorrelatedOver(ResourceToKeywordFields.KeywordID == KeywordFields.ID).CountRow().As(CountFieldName)
                );

the only difference being that this query has no inheritance on ResourceToKeyword.

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 07-Feb-2018 20:23:49   

LLBLGen 4.2 and this is the resulting SQL

SELECT
  [ClassGroup].[ID],
  [ClassGroup].[Name],
  [ClassGroup].[YearGroup],
  [ClassGroup].[TeacherID],
  [ClassGroup].[Teacher2ID],
  [ClassGroup].[AssistantID],
  [ClassGroup].[Assistant2ID],
  [ClassGroup].[Email],
  [ClassGroup].[IsFinesActive],
  (
SELECT
  COUNT(*) AS [LPAV_] 
FROM
  [Borrower]   
WHERE
  ( [User].[ClassGroupID] = [ClassGroup].[ID])) AS [Count] 
FROM
  [ClassGroup]
Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 08-Feb-2018 16:19:18   

Which LLBLGen runtime library version are you using?

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 08-Feb-2018 16:21:32   

4.2 as per last message. 4.2.15.309 to be exact

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 08-Feb-2018 16:26:37   

Could you please try the latest release of v.4.2?

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 08-Feb-2018 16:44:05   

Is there a fix in there for this as a known problem?

(I'm really not in a position to change things on the off-chance at the moment. And I will be moving to 5.3 when I have some time)

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 08-Feb-2018 16:46:14   

I'm suspecting a bug fix that might be related to this issue. That's why I'm suggesting the latest release.

At least you can give it a try in a copy of your project.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 09-Feb-2018 09:32:49   

Could be this fix: Fix Runtime Libraries 4.2 07082015 08-Jul-2015 QuerySpec: In some cases a correlation predicate wasn't properly wrapped as a correlation predicate which could lead to problems when the correlation predicate was used on a nested query with inheritance inside exists (and related operators) queries.

Frans Bouma | Lead developer LLBLGen Pro