- add additional conditions to your query with pertain to a related entity
- return columns from two entities within only one query (which is more efficient)
Here's a scenario:
You have a Product lookup on the Lead entity titled 'Product of Interest' and the Product entity has an option set called 'Product Type'. A query could therefore be to retrieve all Leads that have a Product of Interest where the Product has a 'Product Type' of 'Equipment'.
In C#, your QueryExpression would utilise a LinkEntity and read as follows:The query above retrieves all active Leads in CRM and links their Product of Interest, returning no columns from the Lead and the 'Price' column from the Product.
When retrieving the linked Product's 'Price' from a returned Lead, you might expect to be able to use GetAttributeValue
Note that the attribute you're retrieving from the Lead is "Product.price" not just "price". This is because LinkEntity attributes are prefixed with the EntityAlias property of the LinkEntity object passed to the QueryExpression (see the first code block above).
If you were using DLaB.Xrm and early bound you could just do this:
ReplyDeletevar product = firstLead.GetAliasedEntity();
var price = product.Price.Value;
thank you for your interesting infomation. convert currency
ReplyDelete