CRM 2011 – Quick tip – using EntityLogicalName in query expressions

This is a tiny small tip for writing query expressions and using the EntityLogicalName value.

When you write a queryExpression you have to specify the name of the entity you want to query.

The name is a text string you can create a string and put the name of the entity

                QueryExpression query = new QueryExpression("account");

a better way which makes the code easier to read and will ensure you don’t mistype the query is to use the EntityLogicalName attribute of a CRM entity.  Below is an example of doing a query expression for the account

                QueryExpression query = new QueryExpression(Account.EntityLogicalName);

 

2 thoughts on “CRM 2011 – Quick tip – using EntityLogicalName in query expressions

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