Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Is it possible to express this SQL command as a QueryExpression (requires entity attribute comparison)?

$
0
0

Hi,

I need to create a BulkDeleteRequest and the Query (QuerySet) required looks like this when expressed in SQL:

SELECT *
FROM	[dbo].[vdi_contactrecord] as contactrecord 
INNER JOIN [dbo].[vdi_contactdataset] as dataset
ON dataset.vdi_contactdatasetId = contactrecord.vdi_contactdatasetnameguid
WHERE
	contactrecord.CreatedOn < DATEADD(day,-7,GETDATE())
	AND
	( dataset.vdi_date <> contactrecord.vdi_versiondate
	OR dataset.vdi_version <> contactrecord.vdi_version)


(There will also need to be an additional clause to check the BusinessUnit.)

Is it possible to express the above as a QueryExpression? I can do the join and, I think, the date comparison. The problem I keep running into are those 2 last clauses:  I can find no way to compare an attribute in the first entity with an attribute in the second (linked) entity.  It seems like this basic SQL functionality is entirely missing from QueryExpression - or did I miss something?

Are there alternative approaches that I should consider?


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images