mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 04:18:16 +08:00
## v0.1.13
- 修改 连接池内部 Ping Timeout 值暂定 5秒; - 优化 初始化时若数据库超时,则放弃预热; - FreeSql.Repository 下增加 ISelect.FromRepository 扩展方法,实现分表的多表查询; - 增加 FreeSql.Repository Autofac 泛型注入,可利用实现全局过滤+分表分库; - 补充 GuidRepository 插入数据时,根据 filter 参数设定进行数据验证;
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using repository_01.Repositorys;
|
||||
using FreeSql;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using restful.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -8,14 +8,27 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace restful.Controllers {
|
||||
|
||||
|
||||
[Route("restapi/[controller]")]
|
||||
public class SongsController : Controller {
|
||||
|
||||
SongRepository _songRepository;
|
||||
BaseRepository<Song, int> _songRepository;
|
||||
|
||||
public SongsController(IFreeSql fsql) {
|
||||
_songRepository = new SongRepository(fsql);
|
||||
public class xxxx {
|
||||
public int Id { get; set; }
|
||||
}
|
||||
|
||||
public SongsController(IFreeSql fsql,
|
||||
GuidRepository<Song> repos1,
|
||||
GuidRepository<xxxx> repos2,
|
||||
|
||||
DefaultRepository<Song, int> repos11,
|
||||
DefaultRepository<xxxx, int> repos21,
|
||||
|
||||
BaseRepository<Song> repos3, BaseRepository<Song, int> repos4,
|
||||
IBasicRepository<Song> repos31, IBasicRepository<Song, int> repos41,
|
||||
IReadOnlyRepository<Song> repos311, IReadOnlyRepository<Song, int> repos411
|
||||
) {
|
||||
_songRepository = repos4;
|
||||
|
||||
//test code
|
||||
var curd1 = fsql.GetRepository<Song, int>();
|
||||
|
@ -3,7 +3,7 @@
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:54379/",
|
||||
"applicationUrl": "http://localhost:64150/",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
@ -21,7 +21,7 @@
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:54383/"
|
||||
"applicationUrl": "http://localhost:64154/"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using FreeSql;
|
||||
using restful.Entitys;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace repository_01.Repositorys {
|
||||
public class SongRepository : DefaultRepository<Song, int> {
|
||||
public SongRepository(IFreeSql fsql) : base(fsql, null) {
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
using FreeSql;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using restful.Entitys;
|
||||
using Swashbuckle.AspNetCore.Swagger;
|
||||
using System;
|
||||
using System.Text;
|
||||
@ -23,8 +25,10 @@ namespace repository_01 {
|
||||
public IConfiguration Configuration { get; }
|
||||
public IFreeSql Fsql { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services) {
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services) {
|
||||
|
||||
services.AddSingleton<IFreeSql>(Fsql);
|
||||
//services.AddTransient(s => s.)
|
||||
|
||||
services.AddMvc();
|
||||
services.AddSwaggerGen(options => {
|
||||
@ -34,6 +38,16 @@ namespace repository_01 {
|
||||
});
|
||||
//options.IncludeXmlComments(xmlPath);
|
||||
});
|
||||
|
||||
var builder = new ContainerBuilder();
|
||||
|
||||
builder.RegisterFreeRepository<Song>(a => a.Id == 1);
|
||||
builder.RegisterFreeGuidRepository<Song>(a => a.Id == 1, oldname => $"{oldname}_{DateTime.Now.Year}");
|
||||
|
||||
builder.Populate(services);
|
||||
var container = builder.Build();
|
||||
|
||||
return new AutofacServiceProvider(container);
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
|
||||
|
@ -16,8 +16,4 @@
|
||||
<ProjectReference Include="..\..\FreeSql.Repository\FreeSql.Repository.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user