IDataExtensions.cs.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using System;
  2. using System.Text.RegularExpressions;
  3. using System.Linq;
  4. using System.Data;
  5. namespace SqlSugar
  6. {
  7. public interface IDataAdapter
  8. {
  9. void Fill(DataSet ds);
  10. }
  11. public partial class SqliteProvider : AdoProvider
  12. {
  13. public override void ExecuteBefore(string sql, SugarParameter[] parameters)
  14. {
  15. this.BeforeTime = DateTime.Now;
  16. if (sql.HasValue() && parameters.HasValue())
  17. {
  18. foreach (var parameter in parameters)
  19. {
  20. //Compatible with.NET CORE parameters case
  21. var name = parameter.ParameterName;
  22. if (!sql.Contains(name) && Regex.IsMatch(sql, "(" + name + "$)" + "|(" + name + @"[ ,\,])", RegexOptions.IgnoreCase))
  23. {
  24. parameter.ParameterName = Regex.Match(sql, "(" + name + "$)" + "|(" + name + @"[ ,\,])", RegexOptions.IgnoreCase).Value.Trim();
  25. }
  26. }
  27. }
  28. if (this.IsEnableLogEvent)
  29. {
  30. Action<string, SugarParameter[]> action = LogEventStarting;
  31. if (action != null)
  32. {
  33. if (parameters == null || parameters.Length == 0)
  34. {
  35. action(sql, new SugarParameter[] { });
  36. }
  37. else
  38. {
  39. action(sql, parameters);
  40. }
  41. }
  42. }
  43. }
  44. }
  45. }
  46. namespace System.Data.Sqlite
  47. {
  48. }