DataRowTool.cs 993 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Linq;
  5. using System.Text;
  6. namespace Azylee.Core.DataUtils.DataTableUtils
  7. {
  8. public static class DataRowTool
  9. {
  10. public static string GetValue(DataRow row, string key)
  11. {
  12. string rs = "";
  13. try
  14. {
  15. if (row.Table.Columns.Contains(key))
  16. {
  17. return row[key].ToString();
  18. }
  19. }
  20. catch { }
  21. return rs;
  22. }
  23. public static string GetValueWithNull(DataRow row, string key)
  24. {
  25. string rs = null;
  26. try
  27. {
  28. if (row.Table.Columns.Contains(key))
  29. {
  30. if (!Convert.IsDBNull(row[key]))
  31. {
  32. rs = row[key]?.ToString();
  33. }
  34. }
  35. }
  36. catch { }
  37. return rs;
  38. }
  39. }
  40. }