You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
1.3 KiB

  1. using Furion;
  2. using Microsoft.Extensions.DependencyInjection;
  3. using SqlSugar;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace BPA.KitChen.GroupMeal.SqlSugar
  10. {
  11. public static class SqlsugarSetup
  12. {
  13. /// <summary>
  14. ///
  15. /// </summary>
  16. /// <param name="services"></param>
  17. public static void AddSqlsugarSetup(this IServiceCollection services)
  18. {
  19. //如果多个数数据库传 List<ConnectionConfig>
  20. var configConnection = new ConnectionConfig()
  21. {
  22. DbType = DbType.MySql,
  23. ConnectionString = App.Configuration["DBConnectionStr"],
  24. IsAutoCloseConnection = true
  25. };
  26. var sqlSugar = SqlSugarDb.SqlSugarScope(configConnection);
  27. services.AddSingleton<ISqlSugarClient>(sqlSugar);//这边是SqlSugarScope用AddSingleton
  28. var sqlSugarLog = SqlSugarDb.SqlSugarScopeLog(new ConnectionConfig()
  29. {
  30. DbType = DbType.MySql,
  31. ConnectionString = App.Configuration["DBConnectionLogStr"],
  32. IsAutoCloseConnection = true
  33. });
  34. services.AddSingleton<ISqlSugarClient>(sqlSugarLog);//这边是SqlSugarScope用AddSingleton
  35. }
  36. }
  37. }