Program.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Cksoft.Data;
  2. using Cksoft.Data.Repository;
  3. using Cksoft.Unity.Log4NetConfig;
  4. using System;
  5. using System.Threading.Tasks;
  6. namespace DbTest
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. Console.WriteLine("开始读取数据库");
  13. string connStr = "server=localhost;Port=3306;Database=vipmanage;Uid=root;Pwd=1101210;Charset=utf8;Max Pool Size=100;Allow User Variables=True;SslMode=None;";
  14. Parallel.For(0, 20000, i =>
  15. {
  16. try
  17. {
  18. using (IDatabase db = DbFactory.Base(connStr, DatabaseType.MySql))
  19. {
  20. Console.WriteLine($"第{i + 1}次访问数据库");
  21. var sql = $"select * from function;";
  22. db.FindList<object>(sql);
  23. }
  24. }
  25. catch (Exception e)
  26. {
  27. LogHelper<Program>.LogFatal(e.Message, string.Empty, null);
  28. }
  29. });
  30. Console.ReadKey();
  31. }
  32. }
  33. }