Exemplo n.º 1
0
        /// <summary>
        /// 枚举出属于该聚合的所有的实体类型(深度递归)。
        /// </summary>
        /// <param name="aggtRepository"></param>
        /// <returns></returns>
        public static IEnumerable <IRepository> EnumerateAllTypesInAggregation(IRepository aggtRepository)
        {
            yield return(aggtRepository);

            foreach (var childProperty in aggtRepository.GetChildProperties())
            {
                Type childEntityType = null;
                var  listProperty    = childProperty as IListProperty;
                if (listProperty != null)
                {
                    childEntityType = listProperty.ListEntityType;
                }
                else
                {
                    var refProperty = childProperty as IRefProperty;
                    if (refProperty != null)
                    {
                        childEntityType = refProperty.RefEntityType;
                    }
                    else
                    {
                        throw new NotSupportedException("不支持其它的子属性。");
                    }
                }

                var childRepo = RF.Find(childEntityType);
                foreach (var item in EnumerateAllTypesInAggregation(childRepo))
                {
                    yield return(item);
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 用于查找指定实体的仓库。
 /// </summary>
 /// <typeparam name="TEntity"></typeparam>
 /// <returns></returns>
 public static EntityRepository Find <TEntity>()
     where TEntity : Entity
 {
     return(RF.Find <TEntity>());
 }
Exemplo n.º 3
0
 /// <summary>
 /// 用于查找指定实体的仓库。
 /// </summary>
 /// <returns></returns>
 public static EntityRepository Find(Type entityType)
 {
     return(RF.Find(entityType));
 }