var sql = Db.Select<TableUser, TableOrgan, TableOrgan>()
.InnerJoin((x, y, z) => x.Organ1Id == y.Id)
.InnerJoin((x, y, z) => x.Organ2Id == z.Id)
.ToSql((x, y, z) => new { x, y, z });
Console.WriteLine(sql);
生成后的sql:
SELECT a.`Id` as1, a.`UserName` as2, a.`Organ1Id` as3, a.`Organ2Id` as4, b.`Id` as5, b.`OrganName` as6, b.`Id` as7, b.`OrganName` as8
FROM `TableUser` a
INNER JOIN `TableOrgan` b ON a.`Organ1Id` = b.`Id`
INNER JOIN `TableOrgan` c ON a.`Organ2Id` = c.`Id`
freeSql版本:3.2.820
.net版本:.net 8
问题描述及重现代码:
Join两个相同的表时生成的sql错误,生成后的select语句没有取出c表的字段,而且重复的取出了b表的字段。