2024-06-07 11:04:26 +08:00
|
|
|
|
namespace ZR.CodeGenerator
|
2021-09-13 18:38:54 +08:00
|
|
|
|
{
|
2021-09-16 17:52:31 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 代码生成模板
|
|
|
|
|
|
/// </summary>
|
2021-09-13 18:38:54 +08:00
|
|
|
|
public class CodeGenerateTemplate
|
|
|
|
|
|
{
|
2021-12-11 16:37:08 +08:00
|
|
|
|
//模板调用
|
2021-11-27 17:32:13 +08:00
|
|
|
|
public static string QueryExp(string propertyName, string queryType)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (queryType.Equals("EQ"))
|
|
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName} == parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("GTE"))
|
|
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName} >= parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("GT"))
|
|
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName} > parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("LT"))
|
|
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName} < parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("LTE"))
|
|
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName} <= parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("NE"))
|
|
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName} != parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("LIKE"))
|
|
|
|
|
|
{
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName}.Contains(parm.{propertyName}))";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
2024-06-07 11:04:26 +08:00
|
|
|
|
return $"it => it.{propertyName} == parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
2022-01-05 20:43:18 +08:00
|
|
|
|
|
2021-09-13 18:38:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|