mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-15 14:04:44 +08:00
Subquery Mapping BUG
This commit is contained in:
parent
074b367248
commit
698c0c88de
@ -40,7 +40,6 @@ namespace OrmTest.Demo
|
||||
private static void Subqueryable()
|
||||
{
|
||||
var db = GetInstance();
|
||||
|
||||
var getAll11 = db.Queryable<Student>().Where(it => SqlFunc.Subqueryable<School>().Where(s => s.Id == it.Id).Max(s=>s.Id)==1).ToList();
|
||||
|
||||
var getAll7 = db.Queryable<Student>().Where(it => SqlFunc.Subqueryable<School>().Where(s => s.Id == it.Id).Any()).ToList();
|
||||
|
@ -216,6 +216,13 @@ namespace SqlSugar
|
||||
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||
resolveExpress.MappingTables = Context.MappingTables;
|
||||
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
||||
resolveExpress.InitMappingInfo = this.Context.InitMppingInfo;
|
||||
resolveExpress.RefreshMapping = () =>
|
||||
{
|
||||
resolveExpress.MappingColumns = Context.MappingColumns;
|
||||
resolveExpress.MappingTables = Context.MappingTables;
|
||||
resolveExpress.IgnoreComumnList = Context.IgnoreColumns;
|
||||
};
|
||||
resolveExpress.Resolve(expression, resolveType);
|
||||
this.Parameters.AddRange(resolveExpress.Parameters);
|
||||
var reval = resolveExpress.Result;
|
||||
|
@ -99,6 +99,8 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual string SqlTranslationLeft { get { return "["; } }
|
||||
public virtual string SqlTranslationRight { get { return "]"; } }
|
||||
public virtual Action<Type> InitMappingInfo { get; set; }
|
||||
public virtual Action RefreshMapping { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Core methods
|
||||
@ -143,7 +145,7 @@ namespace SqlSugar
|
||||
else if (isMapping)
|
||||
{
|
||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
||||
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.EntityName) + SqlTranslationRight;
|
||||
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.DbTableName) + SqlTranslationRight;
|
||||
}
|
||||
else if (isComplex)
|
||||
{
|
||||
|
@ -38,7 +38,13 @@ namespace SqlSugar
|
||||
{
|
||||
var exp = expression as MethodCallExpression;
|
||||
var resType = exp.Method.ReturnType;
|
||||
var name = resType.GetGenericArguments().First().Name;
|
||||
var entityType = resType.GetGenericArguments().First();
|
||||
var name = entityType.Name;
|
||||
if (this.Context.InitMappingInfo != null)
|
||||
{
|
||||
this.Context.InitMappingInfo(entityType);
|
||||
this.Context.RefreshMapping();
|
||||
}
|
||||
return "FROM "+this.Context.GetTranslationTableName(name, true);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ namespace SqlSugar
|
||||
ExpressionResult Result { get; set; }
|
||||
string SqlParameterKeyWord { get; }
|
||||
string SingleTableNameSubqueryShortName { get; set; }
|
||||
Action<Type> InitMappingInfo { get; set; }
|
||||
Action RefreshMapping { get; set; }
|
||||
|
||||
string GetAsString(string fieldName, string fieldValue);
|
||||
void Resolve(Expression expression, ResolveExpressType resolveType);
|
||||
|
Loading…
Reference in New Issue
Block a user