日期:2014-05-17  浏览次数:20380 次

一个嵌套查询的问题
本帖最后由 will_stier 于 2013-06-02 22:54:43 编辑
有个部门表

Create Table Departments
(
DepartmentId int identity primary key,
DepartmentName nvarchar(50) not null,
DepartmentNumber nvarchar(50) not null default '',
---上级部门id
        UpDepartmentId int not null default 0,
DepartmentDepth int not null default 1 ,
--0-超管 1-院系,2-行政,3-实训中心.
DepartmentType tinyint not null default 1,
--激活状态, 0-false ,1-yes
Status tinyint default 1,

--权限字符串,值为SPMRight表中的id用,隔开
RightValue nvarchar(max)
)

BLL中有一个GetAll()方法,

       /// <summary>
        /// 获取所有部门,类似select * from [Department],未做筛选和投影
        /// </summary>
        /// <returns></returns>
        public static List<Department> GetAll()
        {
            return DepartmentServices.GetAllDepartments();
        }

现在我需要在GridView中显示的列

选择(复选框,期望批量删除)
部门ID
部门名称
部门编码
上级部门名称(不是id)
删除|编辑
-----
上级部门名称可以为空,如计算机工程系上级部门id为0,则为空。
问:
1.有什么好的办法能够实现?
2.我现在是用ObjectDataSource和GridView绑定的。但是GetAll()显然不能用。怎么办?
3.LINQ语句如何实现?
GridView 编码

------解决方案--------------------
Repeater嵌套查询