8 linq dynamics-crm dynamics-crm-2011
出于某种原因,我说机会实体中不存在"名字".但它是为SystemUser实体设置的.知道为什么会混淆吗?谢谢!
var linqQuery = (from r in gServiceContext.CreateQuery("opportunity")
join c in gServiceContext.CreateQuery("account") on ((EntityReference)r["accountid"]).Id equals c["accountid"]
join u in gServiceContext.CreateQuery("systemuser") on ((EntityReference)r["ownerid"]).Id equals u["systemuserid"]
where r["new_leadstatus"].Equals("100000004") && u["lastname"].Equals(rsmLastName) && u["firstname"].Equals(rsmFirstName)
select new
{
AccountId = !r.Contains("accountid") ? string.Empty : r["accountid"],
Account = !r.Contains("name") ? string.Empty : r["name"]
});
Run Code Online (Sandbox Code Playgroud)
Pet*_*eed 11
确保按照Microsoft准则将每个where子句放在自己的行中.
在其中子句应用滤波器的结果,通常使用一个布尔表达式.过滤器指定要从源序列中排除的元素.每个where子句只能包含针对单个实体类型的条件.涉及多个实体的复合条件无效.相反,应该在单独的where子句中过滤每个实体.
var linqQuery = from r in gServiceContext.CreateQuery("opportunity")
join c in gServiceContext.CreateQuery("account") on ((EntityReference)r["accountid"]).Id equals c["accountid"]
join u in gServiceContext.CreateQuery("systemuser") on ((EntityReference)r["ownerid"]).Id equals u["systemuserid"]
where r["new_leadstatus"].Equals("100000004")
where u["lastname"].Equals(rsmLastName) && u["firstname"].Equals(rsmFirstName)
select new
{
AccountId = !r.Contains("accountid") ? string.Empty : r["accountid"],
Account = !r.Contains("name") ? string.Empty : r["name"]
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
916 次 |
| 最近记录: |