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.
 
 
 

43 lines
999 B

  1. using BAP.Cap.Sqlsugar;
  2. using SqlSugar;
  3. var builder = WebApplication.CreateBuilder(args);
  4. // Add services to the container.
  5. builder.Services.AddCapConfiguration(builder.Configuration);
  6. SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
  7. {
  8. ConnectionString = builder.Configuration.GetSection("ConnectionStrings").Value,//连接符字串
  9. DbType = DbType.SqlServer,//数据库类型
  10. IsAutoCloseConnection = true //不设成true要手动close
  11. }
  12. );
  13. db.Aop.OnLogExecuted = (sql, pars) =>
  14. {
  15. };
  16. builder.Services.AddControllers();
  17. // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
  18. builder.Services.AddEndpointsApiExplorer();
  19. builder.Services.AddSwaggerGen(c =>
  20. {
  21. c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
  22. });
  23. var app = builder.Build();
  24. // Configure the HTTP request pipeline.
  25. if (app.Environment.IsDevelopment())
  26. {
  27. app.UseSwagger();
  28. app.UseSwaggerUI();
  29. }
  30. app.UseAuthorization();
  31. app.MapControllers();
  32. app.Run();