mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
移除 FreeSql.DbContext,成为独立项目
This commit is contained in:
@ -1,24 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user