CommonMethodInfo.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace SqlSugar
  7. {
  8. public class CommonMethodInfo
  9. {
  10. internal object Context { get; set; }
  11. public int ExecuteReturnIdentity()
  12. {
  13. if (Context == null) return 0;
  14. var result = Context.GetType().GetMyMethod("ExecuteReturnIdentity", 0).Invoke(Context, new object[] { });
  15. return (int)result;
  16. }
  17. public async Task<int> ExecuteReturnIdentityAsync()
  18. {
  19. if (Context == null) return 0;
  20. var result = Context.GetType().GetMyMethod("ExecuteReturnIdentityAsync", 0).Invoke(Context, new object[] { });
  21. return await (Task<int>)result;
  22. }
  23. public int ExecuteCommand()
  24. {
  25. if (Context == null) return 0;
  26. var result = Context.GetType().GetMyMethod("ExecuteCommand", 0).Invoke(Context, new object[] { });
  27. return (int)result;
  28. }
  29. public async Task<int> ExecuteCommandAsync()
  30. {
  31. if (Context == null) return 0;
  32. var result = Context.GetType().GetMyMethod("ExecuteCommandAsync", 0).Invoke(Context, new object[] { });
  33. return await (Task<int>)result;
  34. }
  35. }
  36. public class SplitMethodInfo
  37. {
  38. internal object Context { get; set; }
  39. public int ExecuteCommand()
  40. {
  41. if (Context == null) return 0;
  42. var result = Context.GetType().GetMyMethod("ExecuteCommand", 0).Invoke(Context, new object[] { });
  43. return (int)result;
  44. }
  45. public async Task<int> ExecuteCommandAsync()
  46. {
  47. if (Context == null) return 0;
  48. var result = Context.GetType().GetMyMethod("ExecuteCommandAsync", 0).Invoke(Context, new object[] { });
  49. return await (Task<int>)result;
  50. }
  51. }
  52. public class UpdateCommonMethodInfo
  53. {
  54. internal object Context { get; set; }
  55. public int ExecuteCommand()
  56. {
  57. if (Context == null) return 0;
  58. var result = Context.GetType().GetMyMethod("ExecuteCommand", 0).Invoke(Context, new object[] { });
  59. return (int)result;
  60. }
  61. public async Task<int> ExecuteCommandAsync()
  62. {
  63. if (Context == null) return 0;
  64. var result = Context.GetType().GetMyMethod("ExecuteCommandAsync", 0).Invoke(Context, new object[] { });
  65. return await (Task<int>)result;
  66. }
  67. }
  68. }