mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
源代码改用vs默认格式化
This commit is contained in:
@ -3,30 +3,35 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
|
||||
namespace FreeSql {
|
||||
public static class DbContextDependencyInjection {
|
||||
namespace FreeSql
|
||||
{
|
||||
public static class DbContextDependencyInjection
|
||||
{
|
||||
|
||||
public static IServiceCollection AddFreeDbContext<TDbContext>(this IServiceCollection services, Action<DbContextOptionsBuilder> options) where TDbContext : DbContext {
|
||||
public static IServiceCollection AddFreeDbContext<TDbContext>(this IServiceCollection services, Action<DbContextOptionsBuilder> options) where TDbContext : DbContext
|
||||
{
|
||||
|
||||
services.AddScoped<TDbContext>(sp => {
|
||||
var ctx = Activator.CreateInstance<TDbContext>();
|
||||
services.AddScoped<TDbContext>(sp =>
|
||||
{
|
||||
var ctx = Activator.CreateInstance<TDbContext>();
|
||||
|
||||
if (ctx._orm == null) {
|
||||
var builder = new DbContextOptionsBuilder();
|
||||
options(builder);
|
||||
ctx._orm = builder._fsql;
|
||||
if (ctx._orm == null)
|
||||
{
|
||||
var builder = new DbContextOptionsBuilder();
|
||||
options(builder);
|
||||
ctx._orm = builder._fsql;
|
||||
|
||||
if (ctx._orm == null)
|
||||
throw new Exception("请在 OnConfiguring 或 AddFreeDbContext 中配置 UseFreeSql");
|
||||
if (ctx._orm == null)
|
||||
throw new Exception("请在 OnConfiguring 或 AddFreeDbContext 中配置 UseFreeSql");
|
||||
|
||||
ctx.InitPropSets();
|
||||
}
|
||||
ctx.InitPropSets();
|
||||
}
|
||||
|
||||
return ctx;
|
||||
});
|
||||
return ctx;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user