result set using two different views (from an if statement)
Posted
by mailman1979
on Stack Overflow
See other posts from Stack Overflow
or by mailman1979
Published on 2010-06-11T11:01:51Z
Indexed on
2010/06/11
11:32 UTC
Read the original article
Hit count: 191
Hi All,
I have a bit of code that works with a result set called "result" (original I know) but depending on the incoming variable I'd like to fire the specific query depending. I have the below in an if statement but that just makes the "result" recordset gets those nasty red lines and it doesn't work. I'm sure this is easy to work out.
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)
{ etc etc etc
© Stack Overflow or respective owner