SerSqlParameter.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Data.SqlClient;
  5. using System.Linq;
  6. using System.Text;
  7. namespace HPSocketCS.Extended
  8. {
  9. [Serializable]
  10. public class SerSqlParameter
  11. {
  12. public SerSqlParameter(SqlParameter sPara)
  13. {
  14. this.paraName = sPara.ParameterName;
  15. this.paraLen = sPara.Size;
  16. this.paraVal = sPara.Value;
  17. this.sqlDbType = sPara.SqlDbType;
  18. this.Direction = sPara.Direction;
  19. }
  20. public SqlParameter ToSqlParameter()
  21. {
  22. SqlParameter para = new SqlParameter(this.paraName, this.sqlDbType, this.paraLen);
  23. para.Value = this.paraVal;
  24. para.Direction = this.Direction;
  25. return para;
  26. }
  27. private ParameterDirection direction = ParameterDirection.Input;
  28. public ParameterDirection Direction
  29. {
  30. get { return direction; }
  31. set { direction = value; }
  32. }
  33. private string paraName = "";
  34. public string ParaName
  35. {
  36. get { return this.paraName; }
  37. set { this.paraName = value; }
  38. }
  39. private int paraLen = 0;
  40. public int ParaLen
  41. {
  42. get { return this.paraLen; }
  43. set { this.paraLen = value; }
  44. }
  45. private object paraVal = null;
  46. public object ParaVal
  47. {
  48. get { return this.paraVal; }
  49. set { this.paraVal = value; }
  50. }
  51. private SqlDbType sqlDbType = SqlDbType.NVarChar;
  52. public SqlDbType SqlDbType
  53. {
  54. get { return this.sqlDbType; }
  55. set { this.sqlDbType = value; }
  56. }
  57. }
  58. }