Update json 2 sql

This commit is contained in:
sunkaixuan 2024-01-23 17:31:16 +08:00
parent b9a8052546
commit 1be2b165d0
2 changed files with 24 additions and 4 deletions

View File

@ -167,14 +167,19 @@ namespace Test
new SelectModel()
{
AsName = "id1",
FiledName = "id"
FieldName = "id"
},
new SelectModel()
{
FiledName = "id"
FieldName = ObjectFuncModel.Create("MergeString", new string[] {
"Name",
"Name"
}
) ,
AsName="Name"
}
};
};
jsonToSqlClient.Context
.Queryable<object>()
.AS("order").Select(list).ToList();

View File

@ -54,6 +54,10 @@ namespace SqlSugar
{
resSql = GetSqlFuncSql(parameters, dbMethods, methodName, methodInfo, resPars);
}
else if (IsMergeStringMethod(methodName))
{
resSql = GetSqlFuncSql(parameters, dbMethods, methodName, methodInfo, resPars);
}
else
{
resSql = GetNoSupportMethodSql(methodInfo);
@ -61,6 +65,8 @@ namespace SqlSugar
return resSql;
}
private static System.Reflection.MethodInfo GetMethod(IDbMethods dbMethods, string methodName)
{
return dbMethods.GetType().GetMethods()
@ -114,6 +120,10 @@ namespace SqlSugar
IsMember = true
});
}
if (IsMergeStringMethod(methodName))
{
return methodInfo.Invoke(dbMethods, new object[] { args.Select(it=>it.MemberName.ObjToString()).ToArray() }).ObjToString();
}
resSql = methodInfo.Invoke(dbMethods, new object[] { new MethodCallExpressionModel() {
Name=methodName,
Args=args
@ -135,10 +145,15 @@ namespace SqlSugar
private static string GetNoParameterMehtodSql(IDbMethods dbMethods, System.Reflection.MethodInfo methodInfo)
{
return methodInfo.Invoke(dbMethods, new object[] { }).ObjToString();
}
}
#endregion
#region Helper
private static bool IsMergeStringMethod(string methodName)
{
return methodName == "MergeString";
}
private static bool IsSqlFuncMethod(System.Reflection.ParameterInfo[] pars)
{
return pars.First().ParameterType == typeof(MethodCallExpressionModel);