|
- using BAP.Cap.Sqlsugar;
- using SqlSugar;
-
- var builder = WebApplication.CreateBuilder(args);
-
- // Add services to the container.
-
- builder.Services.AddCapConfiguration(builder.Configuration);
-
- SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
- {
- ConnectionString = builder.Configuration.GetSection("ConnectionStrings").Value,//连接符字串
- DbType = DbType.SqlServer,//数据库类型
- IsAutoCloseConnection = true //不设成true要手动close
- }
- );
- db.Aop.OnLogExecuted = (sql, pars) =>
- {
-
- };
- builder.Services.AddControllers();
- // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
- builder.Services.AddEndpointsApiExplorer();
- builder.Services.AddSwaggerGen(c =>
- {
- c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
- });
-
- var app = builder.Build();
-
- // Configure the HTTP request pipeline.
- if (app.Environment.IsDevelopment())
- {
- app.UseSwagger();
- app.UseSwaggerUI();
- }
-
- app.UseAuthorization();
-
- app.MapControllers();
-
- app.Run();
|