2021-09-22 20:25:43 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Linq;
|
2021-09-24 18:37:51 +08:00
|
|
|
|
using System.Text;
|
2021-09-18 16:10:34 +08:00
|
|
|
|
using ZR.Model.System.Generate;
|
2021-09-13 18:38:54 +08:00
|
|
|
|
|
|
|
|
|
|
namespace ZR.CodeGenerator
|
|
|
|
|
|
{
|
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"))
|
|
|
|
|
|
{
|
2022-01-18 21:29:31 +08:00
|
|
|
|
return $"it => it.{ propertyName} == parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("GTE"))
|
|
|
|
|
|
{
|
2022-01-18 21:29:31 +08:00
|
|
|
|
return $"it => it.{ propertyName} >= parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("GT"))
|
|
|
|
|
|
{
|
2022-01-18 21:29:31 +08:00
|
|
|
|
return $"it => it.{ propertyName} > parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("LT"))
|
|
|
|
|
|
{
|
2022-01-18 21:29:31 +08:00
|
|
|
|
return $"it => it.{ propertyName} < parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("LTE"))
|
|
|
|
|
|
{
|
2022-01-18 21:29:31 +08:00
|
|
|
|
return $"it => it.{ propertyName} <= parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("NE"))
|
|
|
|
|
|
{
|
2022-01-18 21:29:31 +08:00
|
|
|
|
return $"it => it.{ propertyName} != parm.{propertyName})";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (queryType.Equals("LIKE"))
|
|
|
|
|
|
{
|
2022-01-18 21:29:31 +08:00
|
|
|
|
return $"it => it.{ propertyName}.Contains(parm.{propertyName}))";
|
2021-11-27 17:32:13 +08:00
|
|
|
|
}
|
2022-02-09 21:20:43 +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
|
|
|
|
}
|
|
|
|
|
|
}
|