Esempio n. 1
0
        /// <summary>
        /// 设置指定实体类的UnitOfWork
        /// </summary>
        public static void SetEntityUnitOfWork(this ScopedDictionary dict, Type entityType, IUnitOfWork unitOfWork)
        {
            string key = $"UnitOfWork_EntityType_{entityType.FullName}";

            dict.TryAdd(key, unitOfWork);
        }
Esempio n. 2
0
 /// <summary>
 /// 获取所有实体类的UnitOfWork
 /// </summary>
 public static IUnitOfWork[] GetEntityUnitOfWorks(this ScopedDictionary dict)
 {
     return(dict.Where(m => m.Key.StartsWith("UnitOfWork_EntityType_")).Select(m => m.Value as IUnitOfWork).ToArray());
 }
Esempio n. 3
0
        /// <summary>
        /// 获取指定实体类的UnitOfWork
        /// </summary>
        public static IUnitOfWork GetEntityUnitOfWork(this ScopedDictionary dict, Type entityType)
        {
            string key = $"UnitOfWork_EntityType_{entityType.FullName}";

            return(dict.GetValue <IUnitOfWork>(key));
        }
Esempio n. 4
0
        /// <summary>
        /// 设置连接串的UnitOfWork
        /// </summary>
        public static void SetConnUnitOfWork(this ScopedDictionary dict, string connString, IUnitOfWork unitOfWork)
        {
            string key = $"UnitOfWork_ConnString_{connString}";

            dict.TryAdd(key, unitOfWork);
        }
Esempio n. 5
0
 /// <summary>
 /// 获取所有连接串的UnitOfWork
 /// </summary>
 public static IUnitOfWork[] GetConnUnitOfWorks(this ScopedDictionary dict)
 {
     return(dict.Where(m => m.Key.StartsWith("UnitOfWork_ConnString_")).Select(m => m.Value as IUnitOfWork).ToArray());
 }
Esempio n. 6
0
        /// <summary>
        /// 获取连接串的UnitOfWork
        /// </summary>
        public static IUnitOfWork GetConnUnitOfWork(this ScopedDictionary dict, string connString)
        {
            string key = $"UnitOfWork_ConnString_{connString}";

            return(dict.GetValue <IUnitOfWork>(key));
        }