using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotline.Repository.SqlSugar.Extensions
{
    public static class WexDbExtensions
    {
        public static void AddWexDb(this IServiceCollection services, IConfiguration configuration, string dbName = "Wex")
        {
            var a = configuration.GetConnectionString(dbName);
            SqlSugarScope sqlSugar = new SqlSugarScope(new ConnectionConfig()
            {
                DbType = DbType.MySql,
                ConnectionString = configuration.GetConnectionString(dbName),
                IsAutoCloseConnection = true,
            },
                db => { }
            );

            ISugarUnitOfWork<WexDbContext> context = new SugarUnitOfWork<WexDbContext>(sqlSugar);
            services.AddSingleton(context);
        }
    }
}
