var roles = from aa in(
from a in dc.SysOrganizationRoleUser
join b in dc.SysOrganizationRole on a.SysRoleID equals b.SysRoleID
join c in dc.SysOrganizationRoleFunctionItem on b.SysRoleID equals c.SysRoleID
join d in dc.SysFunctionItem on c.SysFunctionItemID equals d.SysFunctionItemID
join d2 in dc.SysFunctionItem on c.SysFunctionItemID equals d2.SysFunctionItemID
where a.SysUserID == userID
select d)
from bb in dc.SysFunctionItem
where aa.SysFunctionItemID == bb.SysFunctionItemID || aa.FatherFunctionItemID == bb.SysFunctionItemID
select bb;
var svcUser = from a in hdc.SysServiceCenterUser
join b in hdc.SysServiceCenter on a.SysServiceCenterID equals b.SysServiceCenterID
join c in hdc.SysServicePositionUser on a.SysUserID equals c.SysUserID into pous
from c in pous.DefaultIfEmpty()
join d in hdc.SysServiceCenterPosition on c.SysServicePositionID equals d.SysServicePositionID into po
from d in po.DefaultIfEmpty()
where (_SysServiceCenterID == 0 ? true : a.SysServiceCenterID == _SysServiceCenterID)
&& (_SysServicePositionID == 0 ? true : (from w in hdc.SysServicePositionUser where w.SysServicePositionID == _SysServicePositionID select w.SysUserID).Contains(a.SysUserID))
&& (_Name == null || _Name.Trim() == "" ? true : a.FullName.Contains(_Name))
&& (_Code == null || _Code.Trim() == "" ? true : a.Code == _Code)
select new Svc
{
_SysUserID = (a.SysUserID == null ? 0 : a.SysUserID),
_SysServiceCenterID = (a.SysServiceCenterID==null?0:(int)a.SysServiceCenterID),
//_SysServicePositionID = (int)c.SysServicePositionID,
_SvcName = b.Name,
//_PositionName = d.Name,
_LoginName = a.LoginName,
_FullName = a.FullName,
_Code = (a.Code==null?"":a.Code)
};