我不知道这个查询有什么问题 - 它一直给我这个错误:
Unable to create a constant value of type 'OvertimeProject.DataCore.tbl_Promotion'. Only primitive types or enumeration types are supported in this context.
这是我的 linq 声明:
public IEnumerable<StaffJoin> GetOrderStaffByDepartment(int DepID, DateTime DATE)
{
using (var Context = new CRMDBEntities())
{
var result = (from pro2 in Context.tbl_Promotion
where pro2.PromotionDate <= DATE && pro2.DepID==DepID
select pro2).ToList();
var result2 = (from Re in result
group Re by Re.StaffID into g2
join prop in Context.tbl_Promotion on g2.Max(c => c.PromotionID) equals prop.PromotionID
select prop).ToList();
var result3 = (from s in Context.tbl_STaff
join
promotion in result2 on s.StaffID equals promotion.StaffID
join
position in Context.tbl_Position on promotion.PositionID equals position.PositionID
select new StaffJoin{Staff= s,Promotion= promotion,Position= position}).ToList();
return result3;
}
}
这是我想用返回的数据填充的课程:
public class StaffJoin
{
public tbl_STaff Staff { get; set; }
public tbl_Promotion Promotion { get; set; }
public tbl_Position Position { get; set; }
}
...这是我的带有导航属性的模型结构:
tbl_Staff tbl_Promotion tbl_Position
--------- -------------- -------------
StaffID 0.1 PromotionID 0.1 PositionID
DepID PromotionDate PositionName
StaffName * StaffID PositionBase
Chek PositionID * Avaiilibilty
Avilibility
------- --------------- --------------
Navigation Navigation Navigation
---------- -------------- ----------------
tbl_Department tbl_Position tbl_Promotion
tbl_Promotion tbl_Staff
我需要的是这个:
特定部门的所有员工加上特定日期后每位员工的最高晋升上限,以及与晋升相关的职位信息