using FreeSql; using System; using System.Collections.Generic; using System.Collections.Concurrent; using System.Text; public static class IFreeSqlExtenssions { /// /// 返回默认仓库类 /// /// /// /// /// public static DefaultRepository GetRepository(this IFreeSql that) where TEntity : class { return dicGetRepository.GetOrAdd(typeof(TEntity), type1 => new ConcurrentDictionary()) .GetOrAdd(typeof(TKey), type2 => new DefaultRepository(that)) as DefaultRepository; } static ConcurrentDictionary> dicGetRepository = new ConcurrentDictionary>(); /// /// 返回仓库类,适用 Insert 方法无须返回插入的数据 /// /// /// /// public static GuidRepository GetGuidRepository(this IFreeSql that) where TEntity : class { return dicGetGuidRepository.GetOrAdd(typeof(TEntity), type1 => new GuidRepository(that)) as GuidRepository; } static ConcurrentDictionary dicGetGuidRepository = new ConcurrentDictionary(); }