SDK 5.0.13 : Yes! you can get only metadata you want!
Today, I want to share a really nice feature that was shipped with the latest version of the SDK: the possibility to query metadata (entity, attribute, relationships,…). Before this update, we have to get so many data just to have an entity object type code or icon url.
Now, you can query just what you want (filter) and select what data will be returned: so cool!
Here is a quick sample that returns only custom entities logical name and object type code
var filter = new MetadataFilterExpression(LogicalOperator.And);
filter.Conditions.Add(new MetadataConditionExpression("IsCustomEntity", MetadataConditionOperator.Equals, true));
var properties = new MetadataPropertiesExpression();
properties.PropertyNames.AddRange("LogicalName", "ObjectTypeCode");
//An entity query expression to combine the filter expressions and property expressions for the query.
var entityQueryExpression = new EntityQueryExpression { Criteria = filter, Properties = properties };
//Retrieve the metadata for the query without a ClientVersionStamp
var retrieveMetadataChangesRequest = new RetrieveMetadataChangesRequest
{
Query = entityQueryExpression,
ClientVersionStamp = null,
DeletedMetadataFilters = DeletedMetadataFilters.OptionSet
};
var response = (RetrieveMetadataChangesResponse) service.Execute(retrieveMetadataChangesRequest);
Comments