我有这个sql statemenet,现在想把这个sql改成linq c#
Declare @PageMenuId int
set @PageMenuId=131
select * from MenuMaster as M
left join DynamicPages as P ON M.MenuId=P.PageMenuID
where P.Id is null or P.PageMenuID =@PageMenuId
我试过这个但是现在它不适合我。
MenuMaster objMenuMaster = new MenuMaster();
DynamicPageManager objDynamicPage = new DynamicPageManager();
IList<MenuMaster> lstMenuMaster = new List<MenuMaster>();
IList<DynamicPage> lstDynamicPage = new List<DynamicPage>();
IList<MenuMaster> resultMenuMaster = new List<MenuMaster>();
try
{
lstMenuMaster = GetAll().ToList();
lstDynamicPage = objDynamicPage.GetAll().ToList();
resultMenuMaster = from m in lstMenuMaster
join p in lstDynamicPage on m.MenuId equals p.PageMenuID into gj
from subpet in gj.DefaultIfEmpty()
where (subpet.Id == null) || (subpet.PageMenuID == PageId)
select new MenuMaster {
};
}
catch (Exception ex)
{
_ErrorLog.CreateErrorLog(ex.Message, ex);
}
return resultMenuMaster;