简体   繁体   中英

Fluent BQL producing unexpected SQL for join

I'm using Fluent BQL to join a CreatedByID column to Users, to get the user name (simple example below).

public SelectFrom<GIDesign>
    .InnerJoin<CreatedUsers>.On<CreatedUsers.pKID.IsEqual<GIDesign.createdByID>>
    .OrderBy<GIDesign.name.Asc>.View GIs;

However, the SQL join condition ends up like this...

INNER JOIN [Users] [CreatedUsers_Users] ON NULL = [GIDesign].[CreatedByID] 
AND ( [CreatedUsers_Users].[CompanyID] IN ( 1, 2) 
AND 8 = SUBSTRING( [CreatedUsers_Users].[CompanyMask], 1, 1) & 8) 
AND [CreatedUsers_Users].[DeletedDatabaseRecord] = 0 

The join condition NULL = CreatedByID is of course returning no records. I tried swapping the left and right side of the join and then get this as the first join condition:

INNER JOIN [Users] [CreatedUsers_Users] ON [GIDesign].[CreatedByID] = 
AND ...

Notice the missing right side of the equation? What am I missing, or doing wrong?

I was able to solve it myself shortly after I posted this. I removed the PXProjection attributes, added a Serializable attribute, plus removed PK member classes I had added to try to resolve the issue. So one of these changes must have been the key.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM