我有一段代碼與結果集稱爲「結果」(原來我知道),但取決於傳入的變量我想要觸發特定查詢依賴。我有一個if語句中的下面,但這只是讓「結果」記錄集得到那些討厭的紅線,它不起作用。我相信這很容易解決。結果集使用兩個不同的視圖(從一個if語句)
if (area == "dashboard")
{
IQueryable<ViewGetNavigationMainItem> result = (from m in
_entities.ViewGetNavigationMainItems
where m.area.Trim() == area.Trim()
where m.state == "Online"
where m.parentID == parentID
orderby m.sequence ascending
select m);
}
else
{
//Get the Content Items
IQueryable<ViewGetNavigationContentItem> result = (from m in
_entities.ViewGetNavigationContentItems
where m.navID == navID
where m.parentID == parentID
orderby m.contentOrder ascending
select m);
}
maxRecords = result.Count();
foreach (var item in result)
{
//do something
}
你的問題到底是什麼? – 2010-06-11 11:23:08