I am trying to execute this query to retrieve Audit items for specific entity types
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();
}
The a.ObjectId != null && a.ObjectId.LogicalName == entityType && clause is causing problems. I know .Equals() may cause problems (hence ==) and there are these limitations to the LINQ Provider:
The left side of the clause must be an attribute name and the right side of the clause must be a value
The left side is a property and the right side is a constant. Is the .ObjectId.LogicalName causing the problem?