Browse Source

Update exp to sql

pull/15/MERGE
sunkaixuan 3 years ago
parent
commit
2dd4dc1f97
  1. 20
      Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs
  2. 8
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

20
Src/Asp.Net/SqlSugar/Abstract/QueryableProvider/QueryableProvider.cs

@ -1360,7 +1360,15 @@ namespace SqlSugar
var entity = this.Context.EntityMaintenance.GetEntityInfo<ParameterT>();
var queryableContext = this.Context.TempItems["Queryable_To_Context"] as MapperContext<ParameterT>;
var list = queryableContext.list;
var pkName = (((mappingFiled as LambdaExpression).Body as UnaryExpression).Operand as MemberExpression).Member.Name;
var pkName = "";
if ((mappingFiled as LambdaExpression).Body is UnaryExpression)
{
pkName = (((mappingFiled as LambdaExpression).Body as UnaryExpression).Operand as MemberExpression).Member.Name;
}
else
{
pkName = ((mappingFiled as LambdaExpression).Body as MemberExpression).Member.Name;
}
var key = thisFiled.ToString() + typeof(ParameterT).FullName + typeof(T).FullName;
var ids = list.Select(it => it.GetType().GetProperty(pkName).GetValue(it)).ToArray();
if (queryableContext.TempChildLists == null)
@ -1379,7 +1387,15 @@ namespace SqlSugar
});
queryableContext.TempChildLists[key] = result;
}
var name = (((thisFiled as LambdaExpression).Body as UnaryExpression).Operand as MemberExpression).Member.Name;
var name = "";
if ((thisFiled as LambdaExpression).Body is UnaryExpression)
{
name = (((thisFiled as LambdaExpression).Body as UnaryExpression).Operand as MemberExpression).Member.Name;
}
else
{
name = ((thisFiled as LambdaExpression).Body as MemberExpression).Member.Name;
}
var pkValue = parameter.GetType().GetProperty(pkName).GetValue(parameter);
result = result.Where(it => it.GetType().GetProperty(name).GetValue(it).ObjToString() == pkValue.ObjToString()).ToList();
return result;

8
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/MethodCallExpressionResolve.cs

@ -1056,6 +1056,14 @@ namespace SqlSugar
{
return $"CONVERT(varchar(100),convert(datetime,{value}), 120)";
}
else if (formatString == "yyyy-MM-dd HH:mm" && IsSqlServer())
{
return $"CONVERT(varchar(16),convert(datetime,{value}), 120)";
}
else if (formatString == "yyyy-MM-dd hh:mm" && IsSqlServer())
{
return $"CONVERT(varchar(16),convert(datetime,{value}), 120)";
}
else if (formatString == "yyyy-MM-dd hh:mm:ss.ms" && IsSqlServer())
{
return $"CONVERT(varchar(100),convert(datetime,{value}), 121)";

Loading…
Cancel
Save