CoreConverter.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Core.Mes.Client.Comm
  6. {
  7. public class CoreConverter
  8. {
  9. /// <summary>
  10. /// 生成SQL where条件字符串 "and condition in('args[1],args[2],...')"
  11. /// </summary>
  12. /// <param name="column">列名</param>
  13. /// <param name="args">参数项</param>
  14. /// <returns></returns>
  15. public static String toSqlConditionString(String column, String[] args)
  16. {
  17. StringBuilder str = new StringBuilder();
  18. if (args != null && args.Length > 0)
  19. {
  20. str.Append(" AND ");
  21. str.Append(column.ToUpper());
  22. str.Append(" IN(");
  23. foreach (String arg in args)
  24. {
  25. str.Append("'");
  26. str.Append(arg);
  27. str.Append("',");
  28. }
  29. str.Remove(str.Length - 1, 1);
  30. str.Append(")");
  31. }
  32. return str.ToString();
  33. }
  34. }
  35. }