using FreeSql;
using System;
using System.Collections.Concurrent;
public static class FreeSqlDbContextExtenssions {
///
/// 创建普通数据上下文档对象
///
///
///
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 void SetDbContextOptions(this IFreeSql that, Action options) {
if (options == null) return;
var cfg = _dicSetDbContextOptions.GetOrAdd(that, t => new DbContextOptions());
options(cfg);
_dicSetDbContextOptions.AddOrUpdate(that, cfg, (t, o) => cfg);
}
internal static ConcurrentDictionary _dicSetDbContextOptions = new ConcurrentDictionary();
}