【发布时间】:2012-05-02 22:19:31
【问题描述】:
我正在尝试使用 LINQ 从 Dynamics CRM 2011 中获取一些数据。目标是使所有联系人记录自特定日期以来发生更改或子实体(PERC 文件)自同一日期以来发生更改。查询如下所示:
// Bring all students who have changes (at Contact entity) after specific date
// momentInTime or the status of any of their perc files has been changed since
// that date
var students = (from c in ContactSet
join pl in cga_portallogonSet on c.Id equals pl.cga_ContactId.Id
join ef in cga_percfileSet on c.Id equals ef.cga_StudentId.Id
where
(pl.cga_PortalLogonRole.Value == 284970000) // student
where
(c.ModifiedOn >= momentInTime || c.CreatedOn > momentInTime)
||
(ef.cga_statuschangedate >= momentInTime)
select c.cga_StudentNumber).Distinct().ToList();
这会产生以下错误消息:
'Contact' 实体不包含 Name = 'cga_statuschangedate' 的属性。
我不知道如何对两个不同的实体进行 OR。 MSDN 说每个实体都需要 WHERE 子句:
where 子句
为了过滤结果集,可以针对一个或多个实体添加 where 子句。每个 where 子句只能包含针对单个实体类型的条件。 >涉及多个实体的复合条件无效。相反,每个实体 > 应该在单独的 where 子句中过滤。
http://msdn.microsoft.com/en-us/library/ff681565.aspx
还有其他方法可以实现我的需要吗?
【问题讨论】:
标签: linq dynamics-crm-2011 dynamics-crm crm microsoft-dynamics