linq语句第一条成功 第二条语句查询失败
第一次查询成功
string MenuRoleID = RoleList[0].MenuRoleID.ToString();
MenuRoleList = CommonDbContext.MenuRole.SqlQuery("select * from MenuRole where MenuRoleID='" + MenuRoleID + "'").ToList();
//比对菜单类型。然后得到该菜单类型
List<int> AttrType = new List<int>();
MenuMainListAttr = CommonDbContext.MenuMain.SqlQuery("select * from MenuMain").ToList();
if (MenuMainListAttr.Count > 0)
{
for (int Y = 0; Y < MenuMainListAttr.Count; Y++)
{
AttrType.Add(MenuMainListAttr[Y].MenuType);
}
}
int DetailNum = Convert.ToInt32(Detail);
var query = (from P in CommonDbContext.Menus
where P.MenuDepart == DetailNum && AttrType.Contains(P.MenuType)
select new
{
P.MenuType
}
).Distinct().ToList();
第二次查询失败 执行命令定义时出错
List<int> ArrayMenu = new List<int>();
ArrayMenu.Add(1);
ArrayMenu.Add(2);
ArrayMenu.Add(3);
ArrayMenu.Add(4);
ArrayMenu.Add(5);
ArrayMenu.Add(6);
int NumMenuId = Convert.ToInt32(MenuRoleID);
var Depquery = (from S in CommonDbContext.MenuRole where S.MenuRoleID == NumMenuId && ArrayMenu.Contains(S.DepID)
select new
{
S.DepID