using FreeSql; using System; using System.Collections.Concurrent; using System.Collections.Generic; public static partial class FreeSqlDbContextExtensions { /// /// 创建普通数据上下文档对象 /// /// /// public static DbContext CreateDbContext(this IFreeSql that) { return new FreeContext(that); } /// /// 不跟踪查询的实体数据(在不需要更新其数据时使用),可提升查询性能 /// /// /// /// public static ISelect NoTracking(this ISelect select) where T : class { return select.TrackToList(null); } /// /// 设置 DbContext 选项设置 /// /// /// public static IFreeSql SetDbContextOptions(this IFreeSql that, Action options) { if (options == null) return that; var cfg = _dicSetDbContextOptions.GetOrAdd(that.Ado.Identifier, t => new DbContextOptions()); options(cfg); _dicSetDbContextOptions.AddOrUpdate(that.Ado.Identifier, cfg, (t, o) => cfg); return that; } internal static ConcurrentDictionary _dicSetDbContextOptions = new ConcurrentDictionary(); }