Hi,
I am trying to create a linq query which contains a few subqueries. The query I have created seems to be correct (at least, in syntax) but I get no data sent back and Fiddler is showing an error with this query:
public IQueryable<vGatekeeperApproval> GetGatekeeperApprovals(string UserName)
{
SystemsFormsDataContext db = new SystemsFormsDataContext();
IQueryable<vGatekeeperApproval> query;
Int32 UserId = GetCurrentUserId(UserName);
bool IsGatekeeperApprover = IsCurrentUserGKApprover(UserName);
string strSysApproverEmail = GetSystemsApproverEmail(UserName);
try
{
query = (from s in db.vGatekeeperApprovals
join r in db.Requests on s.RequestId equals r.Id
where (IsGatekeeperApprover == true || s.OverrideApproverId == UserId)
&& (
(
from u in db.Staffs
where u.GateKeeperArea ==
(from c in db.vGK_DIV_USING_CCs
where c.SEGMENT_CODE ==
(from a in db.Attributes
where a.AttributeItemId== global_COSTCENTRE && a.FormId==s.Id
select a.AttributeValue).FirstOrDefault()
select c.PARENT_CODE_L3
).FirstOrDefault()
select u.Id
).ToList().Contains(UserId)
)
select s
);
}
catch (Exception ex)
{
query = (from s in db.vGatekeeperApprovals
where s.UserId == 0
select s);
//LogEvent("ERROR!" + ex.Message, ex.Source);
}
return query;
}
Any ideas what is causing the problem? Is there a better way to create a subquery in linq?
Any help would be greatly appreciated.
Shuja
No comments:
Post a Comment