-
Notifications
You must be signed in to change notification settings - Fork 2
Entity Extensions
Set of extension methods for Microsoft.Xrm.Sdk.Entity base class.
Simplifies getting values from Entity.FormattedValues collection.
public String GetFormatedValue(String attributeLogicalName);
Introduced in version 1.0.37 Simplifies getting values from Entity.FormattedValues collection.
public String GetFormatedValue(string attributeLogicalName, string alias);
Simplifies getting values from linked entities attributes wraped in AliasedValue class. This kind of attributes can be queried by FetchExpression or QueryExpression using Linked Entities.
public T GetAliasedValue<T>(String attributeLogicalName, String alias);
Simplifies getting multiple linked entitiy attrubutes by allocating them to separate Entity.
public Entity GetAliasedEntity(String entityLogicalName, String alias = null);
Generic version of GetAliasedEntity.
public T GetAliasedEntity<T>(String entityLogicalName, String alias = null) where T : Entity;
Add attributes form source Entity if they don't exist in target Entity. Very convenient way to compose attribute values from plugin Target and PreImage to operate single Entity instance.
public void MergeAttributes(Entity source);
Safely sets attribute value.
public bool SetAttributeValue(String name, Object value);
Introduced in version 1.0.37
As it turns out, OOB ToEntityReference method is not copying KeyAttributes collection. New parameter has to be added to be valid override of ToEntityReference.
public EntityReference ToEntityReference(bool withKeys);
Introduced in version 2.2.0
Remove attributes form target Entity if they have the same value in source Entity
Note that EntityCollection attributes are compared only by Entity Id's
public void RemoveUnchanged(this Entity target, Entity source)
Introduced in version 2.4.0
Update target entity attributes with values from source entity and REMOVE values that didn't change
Note that EntityCollection attributes are compared only by Entity Id's
public void ApplyChanges(Entity source, bool removeUnchanged = true)
Introduced in version 2.4.0
Creates a copy of given Entity
Note that RowVersion, EntityState, ExtensionData and RelatedEntities are not copied
public T Clone<T>(this T entity) where T : Entity, new()
Introduced in version 2.4.0
Create ColumnSet based on entity attributes keys
public ColumnSet ToColumnSet();