Home

Run query without having to remove 'Context'

Is it possible to run the query without having to remove the 'Context.' from all tables?

from caseloads in Context.StaffxClients
join caseloadhx in Context.StaffxClientHxes //This extra join is added to make sure that caseload record is present in both SXC and SXCHX tables. For some instances caseload record was only found in in SXC table.
on new { caseloads.StaffID, caseloads.CLID } equals new { caseloadhx.StaffID, caseloadhx.CLID }
join staff in Context.Staffs on caseloads.StaffID equals staff.StaffID
where caseloads.ProgramID == Session.ProgramID
&& staff.RoleId >= Session.RoleID && staff.Disabled == false
select new { StaffName = staff.FName + ' ' + staff.LName, CLID = caseloads.CLID }

I get the error: The name 'Context' does not exist in the current context

Comments

  • Sure. Change the query language from C# Expression to C# Statements and do this:

    var Context = this;

    var query = from caseloads in Context.StaffxClients
    join caseloadhx in Context.StaffxClientHxes //This extra join is added to make sure that caseload record is present in both SXC and SXCHX tables. For some instances caseload record was only found in in SXC table.
    on new { caseloads.StaffID, caseloads.CLID } equals new { caseloadhx.StaffID, caseloadhx.CLID }
    join staff in Context.Staffs on caseloads.StaffID equals staff.StaffID
    where caseloads.ProgramID == Session.ProgramID
    && staff.RoleId >= Session.RoleID && staff.Disabled == false
    select new { StaffName = staff.FName + ' ' + staff.LName, CLID = caseloads.CLID };

    query.Dump();
Sign In or Register to comment.