我正在尝试执行此查询以检索特定实体类型的审核项目
public List<Audit> GetAuditChangesSince(DateTime since, string entityType)
{
return (from a in OrgContext.CreateQuery<Audit>()
where
a.ObjectId != null && a.ObjectId.LogicalName == entityType &&
a.CreatedOn > since
select a).ToList();
}
Run Code Online (Sandbox Code Playgroud)
该a.ObjectId!= NULL && a.ObjectId.LogicalName ==的EntityType &&条款导致的问题.我知道.Equals()可能会导致问题(因此==)并且LINQ提供程序存在以下限制:
子句的左侧必须是属性名称,子句的右侧必须是值
左侧是属性,右侧是常量.是.ObjectId.LogicalName导致问题吗?
我有一个名为new_trexmail的实体,其中包含一个名为new_contextline的字符串属性.
我正在尝试获取一个实体列表,其中new_contextlineis在定义的列表中.
以下代码失败并显示错误: NotSupportedException: Invalid 'where' condition. An entity member is invoking an invalid property or method.
string[] test = new[]{"aaa", "hhh"};
var query = from n in New_trexmailSet
where test.Contains(n.New_contextline)
select n;
Run Code Online (Sandbox Code Playgroud)
我理解为什么会抛出这个错误,但我想知道是否可以使用XRM进行IN子句的等效.
如果可能的话,我该如何让XRM执行SELECT * FROM new_trexmail WHERE new_contextline in ('aaa', 'hhh')?
谢谢,
大卫