我们在程序启动时, 我们使用 SugarIocServices 进行注入
SugarIocServices.AddSqlSugar(new IocConfig()
{
ConnectionString = "server=.;uid=sa;pwd=sasa;database=SQLSUGAR4XTEST",
DbType = IocDbType.SqlServer,
IsAutoCloseConnection = true//自动释放
});
//注入后就能所有地方使用
DbScoped.SugarScope.Queryable<UserOrgMapping>().Where(it=>it.Id>0).ToList()2016 © donet5.comApache Licence 2.0