/// <summary> /// 将子级数据一并查出 /// </summary> public static TDTO GetWithSub <TDTO, TEntity, TSubDTO, TSubEntity>(this FastAccessor <TDTO, TEntity> accessor, long id, FastAccessor <TSubDTO, TSubEntity> subAcs) where TDTO : class, IGeneralEntity where TEntity : class, IGeneralParentEntity <TSubEntity> where TSubDTO : IGeneralEntity where TSubEntity : class, IGeneralSubEntity { var qry = from pt in accessor.Queryable() join sub in subAcs.Queryable() on pt.Id equals sub.ParentId into subs from item in subs.DefaultIfEmpty() where pt.Id == id select new JoinObj <TEntity, TSubEntity> { Data = pt, Item = item }; return(qry.ToList().CvtObj().MapTo <TDTO>()); }
/// <summary> /// 按父级Id查询 /// </summary> public static List <TDTO> GetByParent <TDTO, TEntity>(this FastAccessor <TDTO, TEntity> accessor, long parentId) where TDTO : IGeneralEntity where TEntity : class, IGeneralSubEntity { return(accessor.QueryList(x => x.ParentId == parentId)); }