LINQ with Multiple Joins and Conditions

When using LINQ in Microsoft Dynamics CRM 2011 that requires multiple joins and conditions, you have to specify a “where” clause per comparison context.

Failing to do so will result in a run-time error: “{entity1 name} entity doesn’t contain attribute with Name = {attribute name}”, where in fact, the attribute that it refers to is supposed to be evaluated against entity2, and it has been incorrectly evaluated against entity1.

Putting a separate “where” clause solves this problem:

Advertisements

One thought on “LINQ with Multiple Joins and Conditions

  1. Do you know how to deal with an ‘or’ condition ? For example, a filter condition like this : entity1.linkedentityproperty1.propertyA == v1 OR entity1.linkedentityproperty2.propertyB == v2
    Some help would be appreciated…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s