public static IList<NameValueCore> FindDepartment(string search)
{
return Repository<Department>
.Find(p =>( p.Name.Contains(search)) && ( p.RegistrationEntityType.Id == ((int)Session["SelectMenu"] == 12 ? 1 : (int)Session["SelectMenu"])))
.Take(40)
.ToList()
.Select(p => new NameValueCore(p.Name, p.Id.ToString()))
.ToList();
}
此部分生成错误:( p.RegistrationEntityType.Id == ((int)Session["SelectMenu"] == 12 ? 1 : (int)Session["SelectMenu"])
答案 0 :(得分:0)
在检查Session
的操作之前:
public static IList<NameValueCore> FindDepartment(string search)
{
int selectMenu = 1;
if(Session["SelectMenu"]!=null)
{
selectMenu=(int)Session["SelectMenu"];
}
return Repository<Department>
.Find(p =>( p.Name.Contains(search)) && ( p.RegistrationEntityType.Id == (selectMenu == 12 ? 1 : selectMenu)))
.Take(40)
.ToList()
.Select(p => new NameValueCore(p.Name, p.Id.ToString()))
.ToList();
}