@ -48,7 +48,7 @@ namespace SqlSugar
var joinInfos = subInfos . Skip ( 1 ) . ToList ( ) ;
var i = 0 ;
var masterShortName = formInfo . ThisEntityInfo . DbTableName + i ;
var queryable = this . context . Queryable < object > ( masterShortName ) . AS ( formInfo . ThisEntityInfo . DbTableName ) ;
var queryable = this . context . Queryable < object > ( ToShortName ( masterShortName ) ) . AS ( formInfo . ThisEntityInfo . DbTableName ) ;
i + + ;
var lastShortName = "" ;
foreach ( var item in joinInfos )
@ -57,21 +57,21 @@ namespace SqlSugar
var pkColumn = item . ThisEntityInfo . Columns . FirstOrDefault ( it = > it . IsPrimarykey ) ;
var navColum = item . ParentEntityInfo . Columns . FirstOrDefault ( it = > it . PropertyName = = item . Nav . Name ) ;
Check . ExceptionEasy ( pkColumn = = null , $"{item.ThisEntityInfo.EntityName} need PrimayKey" , $"使用导航属性{item.ThisEntityInfo.EntityName} 缺少主键" ) ;
var on = $" {shortName}.{queryable.SqlBuilder.GetTranslationColumnName(pkColumn.DbColumnName)}={formInfo.ThisEntityInfo.DbTableName + (i - 1)}.{queryable.SqlBuilder.GetTranslationColumnName(navColum.DbColumnName)}" ;
queryable . AddJoinInfo ( item . ThisEntityInfo . DbTableName , shortName , on , JoinType . Inner ) ;
var on = $" {ToShortName( shortName) }.{queryable.SqlBuilder.GetTranslationColumnName(pkColumn.DbColumnName)}={ToShortName( formInfo.ThisEntityInfo.DbTableName + (i - 1) )}.{queryable.SqlBuilder.GetTranslationColumnName(navColum.DbColumnName)}" ;
queryable . AddJoinInfo ( item . ThisEntityInfo . DbTableName , ToShortName ( shortName ) , on , JoinType . Inner ) ;
+ + i ;
lastShortName = shortName ;
formInfo = item ;
}
var selectProperyInfo = ExpressionTool . GetMemberName ( memberInfo . Expression ) ;
var selectColumnInfo = memberInfo . ParentEntityInfo . Columns . First ( it = > it . PropertyName = = selectProperyInfo ) ;
queryable . Select ( $" {lastShortName}.{queryable.SqlBuilder.GetTranslationColumnName(selectColumnInfo.DbColumnName)}" ) ;
queryable . Select ( $" {ToShortName( lastShortName) }.{queryable.SqlBuilder.GetTranslationColumnName(selectColumnInfo.DbColumnName)}" ) ;
var last = subInfos . First ( ) ;
var FirstPkColumn = last . ThisEntityInfo . Columns . FirstOrDefault ( it = > it . IsPrimarykey ) ;
Check . ExceptionEasy ( FirstPkColumn = = null , $"{ last.ThisEntityInfo.EntityName} need PrimayKey" , $"使用导航属性{ last.ThisEntityInfo.EntityName} 缺少主键" ) ;
var PkColumn = last . ParentEntityInfo . Columns . FirstOrDefault ( it = > it . PropertyName = = last . Nav . Name ) ;
Check . ExceptionEasy ( PkColumn = = null , $"{ last.ParentEntityInfo.EntityName} no found {last.Nav.Name}" , $"{ last.ParentEntityInfo.EntityName} 不存在 {last.Nav.Name}" ) ;
queryable . Where ( $" {this.shorName}.{queryable.SqlBuilder.GetTranslationColumnName(PkColumn.DbColumnName)} = {masterShortName}.{queryable.SqlBuilder.GetTranslationColumnName(FirstPkColumn.DbColumnName)} " ) ;
queryable . Where ( $" {ToShortName( this.shorName) }.{queryable.SqlBuilder.GetTranslationColumnName(PkColumn.DbColumnName)} = {ToShortName( masterShortName) }.{queryable.SqlBuilder.GetTranslationColumnName(FirstPkColumn.DbColumnName)} " ) ;
MapperSql . Sql = "( " + queryable . ToSql ( ) . Key + " ) " ;
return MapperSql ;
}
@ -121,6 +121,17 @@ namespace SqlSugar
#endregion
#region Helper
private string ToShortName ( string name )
{
if ( name . ObjToString ( ) . Contains ( "." ) )
{
return name . Replace ( "." , "_" ) ;
}
else
{
return name ;
}
}
private static bool IsParameter ( Expression child2Expression )
{