请goodday哥指出我的错误
怎么总觉得我写的这段code很傻
Linq 新手 pai seh
我要用session里面User的departmentId对比
objleave里面foreign key userid的 Foreign key department Id
linq好像不能直接跨越两个obj拿去资料
所以我只好分成一个一个obj拿资料,可是他就出现了这个error
Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Unable to create a constant value of type 'Closure type'. Only primitive types ('such as Int32, String, and Guid') are supported in this context.
不懂是什么ERROR第一次看过
objLeaveBLL = new LeaveBLL(context);
string sUser = Session["UserId"].ToString();
string sRole = Session["UserRole"].ToString();
var query1 = from u in context.User
where u.UserId == sUser
select u;
var query2 = from D in context.Department
where D.DepartmentId == query1.FirstOrDefault().Department.DepartmentId
select D;
int ManagerDepartmentId = query2.FirstOrDefault().DepartmentId;
if (sRole == "Manager")
{
LeaveList = objLeaveBLL.GetLeaveByUserRole("Staff");
grv_LeaveApprove.DataSource = LeaveList;
grv_LeaveApprove.DataBind();
var query3 = from L in LeaveList
where L.User.UserId == L.User.UserId
select L.User;
var query4 = from D in context.Department
where D.DepartmentId == query3.FirstOrDefault().Department.DepartmentId
select D;
if (ManagerDepartmentId == query4.FirstOrDefault().DepartmentId )
{
LeaveList = objLeaveBLL.GetLeaveByLeaveApprove("

ending");
grv_LeaveApprove.DataSource = LeaveList;
grv_LeaveApprove.DataBind();
}
}
请把我的错误点出来吧
感谢了
[
本帖最后由 我是大猪头 于 2009-11-15 01:41 PM 编辑 ]