mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 修复 ISelectGrouping ToSql AsProperty 别名无效问题;
This commit is contained in:
		@@ -277,15 +277,23 @@ namespace FreeSql.Internal
 | 
			
		||||
                            return false;
 | 
			
		||||
                        }
 | 
			
		||||
                        if (parent.CsType == null) parent.CsType = exp.Type;
 | 
			
		||||
                        var pdbfield = parent.DbField = ExpressionLambdaToSql(exp, getTSC());
 | 
			
		||||
                        if (parent.MapType == null || _tables?.Any(a => a.Table?.IsRereadSql == true) == true)
 | 
			
		||||
                        try
 | 
			
		||||
                        {
 | 
			
		||||
                            var findcol = SearchColumnByField(_tables, null, parent.DbField);
 | 
			
		||||
                            if (parent.MapType == null) parent.MapType = findcol?.Attribute.MapType ?? exp.Type;
 | 
			
		||||
                            if (findcol != null) pdbfield = _common.RereadColumn(findcol, pdbfield);
 | 
			
		||||
                            var pdbfield = parent.DbField = ExpressionLambdaToSql(exp, getTSC());
 | 
			
		||||
                            if (parent.MapType == null || _tables?.Any(a => a.Table?.IsRereadSql == true) == true)
 | 
			
		||||
                            {
 | 
			
		||||
                                var findcol = SearchColumnByField(_tables, null, parent.DbField);
 | 
			
		||||
                                if (parent.MapType == null) parent.MapType = findcol?.Attribute.MapType ?? exp.Type;
 | 
			
		||||
                                if (findcol != null) pdbfield = _common.RereadColumn(findcol, pdbfield);
 | 
			
		||||
                            }
 | 
			
		||||
                            field.Append(", ").Append(pdbfield);
 | 
			
		||||
                            LocalSetFieldAlias(ref index, _tables != null ||
 | 
			
		||||
                                SelectGroupingProvider._ParseExpOnlyDbField.Value != pdbfield);
 | 
			
		||||
                        }
 | 
			
		||||
                        finally
 | 
			
		||||
                        {
 | 
			
		||||
                            SelectGroupingProvider._ParseExpOnlyDbField.Value = null;
 | 
			
		||||
                        }
 | 
			
		||||
                        field.Append(", ").Append(pdbfield);
 | 
			
		||||
                        LocalSetFieldAlias(ref index, true);
 | 
			
		||||
                        return false;
 | 
			
		||||
                    }
 | 
			
		||||
                    return false;
 | 
			
		||||
 
 | 
			
		||||
@@ -31,6 +31,7 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
            _tables = tables;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public static ThreadLocal<string> _ParseExpOnlyDbField = new ThreadLocal<string>();
 | 
			
		||||
        public override string ParseExp(Expression[] members)
 | 
			
		||||
        {
 | 
			
		||||
            ParseExpMapResult = null;
 | 
			
		||||
@@ -52,7 +53,11 @@ namespace FreeSql.Internal.CommonProvider
 | 
			
		||||
                    }
 | 
			
		||||
                    ParseExpMapResult = read;
 | 
			
		||||
                    if (!_addFieldAlias) return read.DbField;
 | 
			
		||||
                    if (_comonExp.EndsWithDbNestedField(read.DbField, read.DbNestedField) == false) return $"{read.DbField}{_comonExp._common.FieldAsAlias(read.DbNestedField)}";
 | 
			
		||||
                    if (_comonExp.EndsWithDbNestedField(read.DbField, read.DbNestedField) == false)
 | 
			
		||||
                    {
 | 
			
		||||
                        _ParseExpOnlyDbField.Value = read.DbField;
 | 
			
		||||
                        return $"{read.DbField}{_comonExp._common.FieldAsAlias(read.DbNestedField)}";
 | 
			
		||||
                    }
 | 
			
		||||
                    return read.DbField;
 | 
			
		||||
                case "Value":
 | 
			
		||||
                    var curtables = _tables;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user