mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-27 13:12:51 +08:00

- 增加 行级锁功能,适用修改实体; - 增加 FreeSql.Repository 默认依赖注入的方式,同时保留原有 Autofac; - 优化 FreeSql.Repository Insert 逻辑,参考了 FreeSql.DbContext; - 优化 FreeSql.IUpdate 参照 IInsert 对大批量更新,拆分执行; - 修复 FreeSql.IInsert ClearData 重复利用的 bug(使用 IgnoreColumns 进行大批量插入时会发生);
25 lines
599 B
C#
25 lines
599 B
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
|
|
namespace FreeSql {
|
|
public static class DbContextDependencyInjection {
|
|
|
|
public static IServiceCollection AddFreeDbContext<TDbContext>(this IServiceCollection services, Action<DbContextOptionsBuilder> options) where TDbContext : DbContext {
|
|
|
|
services.AddScoped<TDbContext>(sp => {
|
|
var ctx = Activator.CreateInstance<TDbContext>();
|
|
|
|
if (ctx._orm == null) {
|
|
var builder = new DbContextOptionsBuilder();
|
|
options(builder);
|
|
ctx._orm = builder._fsql;
|
|
}
|
|
|
|
return ctx;
|
|
});
|
|
|
|
return services;
|
|
}
|
|
}
|
|
}
|