4

我正在运行以下 LINQ 查询,但它抛出一个错误,提示“无效的 'where' 条件。实体成员正在调用无效的属性或方法。”

谁能建议我为什么会这样。如果我从中删除conn.Record2Id.LogicalName.Equals("account")WHERE会返回结果,但我可以看到 LogicalName = account in quick view

var connections = (from conn in context.CreateQuery<Connection>()                              
                  where (conn.Record1Id.Id.Equals(incidentId) 
                  && conn.Record2Id.LogicalName.Equals("account") 
                  && conn.StateCode == 0)
                  select conn).FirstOrDefault();

提前致谢

4

3 回答 3

4

CRM 的 LINQ 转换器无法处理该.Equals()方法。

将其更改为conn.Record2Id.LogicalName == "account"

于 2013-02-11T16:11:08.983 回答
0

尝试这个:

var connections = (from conn in context.CreateQuery<Connection>()                              
              where conn.Record1Id != null 
              && conn.Record1Id.Id == incidentId 
              && conn.Record2Id != null 
              && conn.Record2Id.LogicalName == "account" 
              && conn.StateCode.Value == 0
              select conn).FirstOrDefault();    
于 2013-02-11T22:31:48.357 回答
0

有趣但试试这个:)

var connections = (from conn in context.CreateQuery<Connection>()                              
                  where (conn.Record1Id == new EntityReference("account",incidentId) 
                  && conn.StateCode == 0)
                  select conn).FirstOrDefault();
于 2016-06-07T16:07:52.263 回答