-
Notifications
You must be signed in to change notification settings - Fork 1
Innofactor.Xrm.Utils.Common
-
ContainerExtensions
- Associate(container,entity,relatedentity,intersect)
- Associate(container,entity,relatedEntities,intersect)
- Associate(entity,container,relatedEntities,intersect,batchSize)
- Attribute(container,name)
- Convert(container,query)
- Create(container,entity)
- Delete(container,entity)
- EndSection()
- Ensure(container,entity,attribute)
- Entity(container,target)
- Entity(container,target)
- Entity(container,logicalName)
- Execute(container,request)
- Execute(container,request)
- Log(message,args)
- Merge(container,entity1,entity2)
- Principal(container,principal)
- Principal(container,principal)
- Reload(container,entity)
- Reload(container,entity,columns)
- Reload(container,entity,columns)
- Retrieve(container,reference,columns)
- Retrieve(container,reference,columnSet)
- Retrieve(container,entityName,id,columns)
- Retrieve(container,entityName,id,columnSet)
- RetrieveMultiple(container,query)
- RetrieveMultiple(container,entity,attribute,value,columns)
- Save(container,entity)
- SetState(container,entity,state,status)
- StartSection(name)
- Update(container,entity)
- EntityCollectionExtensions
- EntityComparer
-
EntityExtensions
- CloneAttributes(entity)
- CloneId(entity)
- Contains(entity,name,notnull)
- GetAttribute``1(entity,attribute,default)
- IsActive(entity,default)
- IsActive(entity)
- Merge(container,entity1,entity2)
- PropertyLinkedEntity``1(entity,linkedEntityAlias,name,default)
- RemoveProperty(entity,name)
- SetAttribute``1(entity,name,value)
- SetOwner(entity,user)
- IExecutionContainer
- OperationsSet1
- OperationsSet1
- OperationsSet2
- OperationsSet2
- OperationsSet2
- OperationsSet3
- OperationsSet4
-
Query
- AppendCondition(filt,type,attr,oper,val)
- AppendConditionActive(filt)
- AppendLink(linkentities,from,to,from_attr,to_attr)
- AppendLink1M(linkentities,from,to)
- AppendLinkM1(linkentities,from,to)
- AppendLinkMM(linkentities,from,to)
- AppendLinkMM(linkentities,intersect,from,to)
- AppendLinkMM(linkentities,intersect,from,from_attr,to,to_attr)
- GetFilterConditionByAttribute(filter,attribute)
- SortAttribute
Innofactor.Xrm.Utils.Common.Extensions
Extension methods for IContainable classes
Associates current record with relatedentity, using specified intersect relationship
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity | Current entity |
relatedentity | Microsoft.Xrm.Sdk.Entity | Related entity |
intersect | System.String | Name of the intersect relationship/entity |
Name | Description |
---|---|
System.ServiceModel.FaultException`1 | may be typed as: |
OrganizationServiceFault: Thrown when association already exists. |
To be used with N:N-relationships.
Associates current record with relatedentities, using specified intersect relationship
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity | |
relatedEntities | Microsoft.Xrm.Sdk.EntityCollection | Collection of the entities to be related to current entity |
intersect | System.String | Name of the intersect relationship/entity |
Name | Description |
---|---|
System.ServiceModel.FaultException`1 | may be typed as: |
OrganizationServiceFault: Thrown when any of the associations already exists. |
To be used with N:N-relationships.
Associates current record with relatedentities, using specified intersect relationship
Name | Type | Description |
---|---|---|
entity | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
container | Microsoft.Xrm.Sdk.Entity | |
relatedEntities | Microsoft.Xrm.Sdk.EntityCollection | Collection of the entities to be related to current entity |
intersect | System.String | Name of the intersect relationship/entity |
batchSize | System.Int32 | Optional. Determines the max number of entities to associate per request |
Name | Description |
---|---|
System.ServiceModel.FaultException`1 | may be typed as: |
OrganizationServiceFault: Thrown when any of the associations already exists. |
To be used with N:N-relationships.
Initiates work with attributes
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
name | System.String |
Converts QueryExpression to FetchXml
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
query | Microsoft.Xrm.Sdk.Query.QueryExpression |
The Guid of the created entity.
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity |
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity |
End section in the log file.
This method has no parameters.
Checks if a property exists in the encapsulated Entity
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity | |
attribute | System.String | Name of property to check |
Initiates work with entitites
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
target | Microsoft.Xrm.Sdk.Entity |
Initiates work with entitites
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
target | Microsoft.Xrm.Sdk.EntityReference |
Initiates work with entitites
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
logicalName | System.String |
Method to be used when retrieving metadata, to be able to benefit from metadata caching abilities
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
request | Microsoft.Xrm.Sdk.Messages.RetrieveEntityRequest | Metadata request |
Method to be used when retrieving metadata, to be able to benefit from metadata caching abilities
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
request | Microsoft.Xrm.Sdk.Messages.RetrieveAttributeRequest | Metadata request |
Write message and parameter values to the log file.
Name | Type | Description |
---|---|---|
message | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
args | System.String |
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity1 | Microsoft.Xrm.Sdk.Entity | |
entity2 | Microsoft.Xrm.Sdk.Entity |
Initiates work with principals which is followed with access related opetations: Grant / Revoke / Assign
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
principal | Microsoft.Xrm.Sdk.Entity |
Initiates work with principals which is followed with access related opetations: Grant / Revoke / Assign
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
principal | Microsoft.Xrm.Sdk.EntityReference |
Reloads encapsulated Entity from database
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity |
ToStringWithEntityName() is replaced with entity.LogicalName
Reloads encapsulated Entity from database
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity | |
columns | System.String[] | Set of colums with which entity should be reloaded |
ToStringWithEntityName() is replaced with entity.LogicalName
Reloads encapsulated Entity from database
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity | |
columns | Microsoft.Xrm.Sdk.Query.ColumnSet | Set of colums with which entity should be reloaded |
ToStringWithEntityName() is replaced with entity.LogicalName
Encapsulated Retrieve method to be invoked on the service
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
reference | Microsoft.Xrm.Sdk.EntityReference | |
columns | System.String[] | Set of colums with which entity should be reloaded |
Encapsulated Retrieve method to be invoked on the service
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
reference | Microsoft.Xrm.Sdk.EntityReference | |
columnSet | Microsoft.Xrm.Sdk.Query.ColumnSet |
Encapsulated Retrieve method to be invoked on the service
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entityName | System.String | |
id | System.Guid | |
columns | System.String[] | Set of colums with which entity should be reloaded |
Encapsulated Retrieve method to be invoked on the service
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entityName | System.String | |
id | System.Guid | |
columnSet | Microsoft.Xrm.Sdk.Query.ColumnSet |
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
query | Microsoft.Xrm.Sdk.Query.QueryBase |
Retrieve objects matching given criteria
EntityCollection that encapsulate the resulting Entity records
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | System.String | Entity's logical name |
attribute | System.String[] | |
value | System.Object[] | |
columns | Microsoft.Xrm.Sdk.Query.ColumnSet |
Save the entity record. If it has a valid Id it will be updated, otherwise new record created.
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity |
Update state and status of current record
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity | |
state | System.Int32 | Active=0 and Inactive=1 |
status | System.Int32 | Active=1 and Inactive=2 |
http://msdynamicscrmblog.wordpress.com/2013/10/26/status-and-status-reason-values-in-dynamics-crm-2013/comment-page-1/ ToStringWithEntityName() is replaced with entity.LogicalName
Starts a section in the log file
Name | Type | Description |
---|---|---|
name | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer |
Name | Type | Description |
---|---|---|
container | Innofactor.Xrm.Utils.Common.Interfaces.IExecutionContainer | |
entity | Microsoft.Xrm.Sdk.Entity |
Innofactor.Xrm.Utils.Common.Extensions
Extension methods for EntityCollection class
Adds entity to current collection
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection | |
entity | Microsoft.Xrm.Sdk.Entity |
Adds range of entities to current collection
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection | |
entities | Microsoft.Xrm.Sdk.EntityCollection |
Checks if specified item is available in the collection. Comparison is strictly by Id.
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection | |
item | Microsoft.Xrm.Sdk.Entity |
Checks if a record with specified id is available in the collection.
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection | |
id | System.Guid |
Counts number of record in current collection
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection |
Returns record with specified id if it's available in the collection.
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection | |
id | System.Guid |
Sort the collection based on given attribute names
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection | |
attributes | System.String[] | Array of attribute names to sort by. Prepend attribute name with ! to sort DESC. |
Turns collection of Entity into collection of EntityReference
Name | Type | Description |
---|---|---|
collection | Microsoft.Xrm.Sdk.EntityCollection |
Innofactor.Xrm.Utils.Common.Misc
A class used to compare cintdynentity instances
Constructor of CintDynEntity class. Takes a list of attribute names as an argument.
Name | Type | Description |
---|---|---|
attributes | System.String[] | The attributes to sort the comparison by...... |
Property returning the configured sort attributes.
The list of sort attributes
The method that performs the actual comparison in the CintDynEntityComparer class.
An integer which is greater than 0 if the x parameter is greater than the y parameter, 0 if they are equal, and negative if x is less than y.
Name | Type | Description |
---|---|---|
x | Microsoft.Xrm.Sdk.Entity | The Entity to compare. |
y | Microsoft.Xrm.Sdk.Entity | The Entity to compare with. |
Innofactor.Xrm.Utils.Common.Extensions
Light-weight features inspired by CintDynEntity
Clones entity instance to a new C# instance
Cloned entity
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity |
Does NOT create a copy in database, just a new copy to work with in code.
Clones entity instance to a new C# instance
Cloned entity
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity |
Does NOT create a copy in database, just a new copy to work with in code.
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity | |
name | System.String | |
notnull | System.Boolean |
Generic method to retrieve property with name "name" of type "T"
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity | |
attribute | System.String | |
default | ``0 |
Name | Description |
---|---|
T |
Gets bool indicating if record is active (writable) or inactive.
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity | |
default | System.Boolean | Default value if statecode is missing in entity. |
Returns true if entity has an active state. If statecode is not available in the attribute collection an exception is thrown.
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity |
Name | Type | Description |
---|---|---|
container | Microsoft.Xrm.Sdk.Entity | |
entity1 | Microsoft.Xrm.Sdk.Entity |
Om entiteten innehåller attribut från länkade entiteter efter läsning så måste aliaset för den länkade entiteten anges.
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity | |
linkedEntityAlias | System.String | |
name | System.String | |
default | ``0 |
Name | Description |
---|---|
T |
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity | |
name | System.String |
Generic method to add property with "name" and set its value of type "T" to "value"
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity | |
name | System.String | |
value | ``0 |
Name | Description |
---|---|
T |
Sätter current user (from context) som owner på entity
Name | Type | Description |
---|---|---|
entity | Microsoft.Xrm.Sdk.Entity | |
user | System.Guid |
Innofactor.Xrm.Utils.Common.Interfaces
Core object that helps to keep all objects and methods needed for CRM development in package easy to access and operate
Get instance of the ITracingService assosiated with current container
Gets instance of IOrganizationService assosiated with current container
Innofactor.Xrm.Utils.Common.Fluent.Access
Innofactor.Xrm.Utils.Common.Fluent.Attribute
Adds information about entity to work with
Name | Type | Description |
---|---|---|
target | Microsoft.Xrm.Sdk.Entity |
Adds information about entity to work with
Name | Type | Description |
---|---|---|
target | Microsoft.Xrm.Sdk.EntityReference |
Adds information about entity to work with
Name | Type | Description |
---|---|---|
target | Microsoft.Xrm.Sdk.Entity |
Innofactor.Xrm.Utils.Common.Fluent.Access
Innofactor.Xrm.Utils.Common.Fluent.Attribute
Innofactor.Xrm.Utils.Common.Fluent.Entity
Primary Id attribute of the entity
Primary Name attribute of the entity
Assigns current record to given principal
This method has no parameters.
Grants access to current record to given principal
Name | Type | Description |
---|---|---|
accessMask | Microsoft.Crm.Sdk.Messages.AccessRights |
Revokes access from current record from given principal
This method has no parameters.
Will add given columns
to the operation
Name | Type | Description |
---|---|---|
columns | Microsoft.Xrm.Sdk.Query.ColumnSet |
Will add given columns
to the operation
Name | Type | Description |
---|---|---|
columns | System.String[] |
Gets a readable string representation of given attribute
Formatted value of the attribute
This method has no parameters.
Get the primary id attribute of the target entity
This method has no parameters.
Metadata request that is time consuming, but results are cached.
Gets primary name attribute of the entity
This method has no parameters.
Innofactor.Xrm.Utils.Common.Fluent.Entity
Sets name
of the attribute or relation via which association was perfomed
Name | Type | Description |
---|---|---|
name | System.String | Name of the attribute or relation |
Innofactor.Xrm.Utils.Common.Fluent.Entity
Add locking flag explicitly
Name | Type | Description |
---|---|---|
value | System.Boolean |
Retrieves records (children) relating to current record (parent)
Name | Type | Description |
---|---|---|
columns | Microsoft.Xrm.Sdk.Query.ColumnSet | ColumnSet to expand |
Will add given columns
to the operation
Name | Type | Description |
---|---|---|
columns | System.String[] |
Add fintering condition to composed query
Name | Type | Description |
---|---|---|
condition | Microsoft.Xrm.Sdk.Query.FilterExpression | FilterExpression to apply |
Add locking flag explicitly
Name | Type | Description |
---|---|---|
value | System.Boolean |
Add sorting order to composed query
Name | Type | Description |
---|---|---|
order | Microsoft.Xrm.Sdk.Query.OrderExpression | OrderExpression to apply |
Add sorting order to composed query
Name | Type | Description |
---|---|---|
attributeName | System.String | |
orderType | Microsoft.Xrm.Sdk.Query.OrderType |
Add sorting order to composed query
Name | Type | Description |
---|---|---|
order | System.Collections.Generic.IEnumerable{Microsoft.Xrm.Sdk.Query.OrderExpression} | Collection of OrderExpression to apply |
Innofactor.Xrm.Utils.Common.Misc
Various utils for retrieving and updating entities and attributes
Appends QueryExpression Condition to the FilterExpression
Name | Type | Description |
---|---|---|
filt | Microsoft.Xrm.Sdk.Query.FilterExpression | FilterExpression to add condition to |
type | Microsoft.Xrm.Sdk.Query.LogicalOperator | Operator for FilterExpression |
attr | System.String | Attribut to apply condition to |
oper | Microsoft.Xrm.Sdk.Query.ConditionOperator | Operator for condition |
val | System.Object | Value to apply operation on |
Appends QueryExpression Condition to verify StateCode=Active
Name | Type | Description |
---|---|---|
filt | Microsoft.Xrm.Sdk.Query.FilterExpression | FilterExpression to add condition to |
Appends QueryExpression linked entity to the LinkEntities list
Name | Type | Description |
---|---|---|
linkentities | Microsoft.Xrm.Sdk.DataCollection{Microsoft.Xrm.Sdk.Query.LinkEntity} | LinkEntities collection to add linked entity to |
from | System.String | Link From entity |
to | System.String | Link To entity |
from_attr | System.String | Attribute name on From entity |
to_attr | System.String | Attribute name on To entity |
Use to generate link between 1:M entities (for standard identifying field names)
Name | Type | Description |
---|---|---|
linkentities | Microsoft.Xrm.Sdk.DataCollection{Microsoft.Xrm.Sdk.Query.LinkEntity} | |
from | System.String | |
to | System.String |
Use to generate link between M:1 entities (for standard identifying field names)
Name | Type | Description |
---|---|---|
linkentities | Microsoft.Xrm.Sdk.DataCollection{Microsoft.Xrm.Sdk.Query.LinkEntity} | |
from | System.String | |
to | System.String |
Use to generate link between N:N entities (for standard identifying field names and intersect table name)
LinkEntity for the To entity
Name | Type | Description |
---|---|---|
linkentities | Microsoft.Xrm.Sdk.DataCollection{Microsoft.Xrm.Sdk.Query.LinkEntity} | |
from | System.String | |
to | System.String |
Use to generate link between N:N entities (for standard identifying field names but non-standard intersect table name)
Name | Type | Description |
---|---|---|
linkentities | Microsoft.Xrm.Sdk.DataCollection{Microsoft.Xrm.Sdk.Query.LinkEntity} | |
intersect | System.String | |
from | System.String | |
to | System.String |
Use to generate link between N:N entities (for non-standard identifying field names and intersect table name)
LinkEntity for the To entity
Name | Type | Description |
---|---|---|
linkentities | Microsoft.Xrm.Sdk.DataCollection{Microsoft.Xrm.Sdk.Query.LinkEntity} | |
intersect | System.String | |
from | System.String | |
from_attr | System.String | |
to | System.String | |
to_attr | System.String |
Gets first found condition for attribute with given name
First found ConditionExpression
, or null if no condition is found
Name | Type | Description |
---|---|---|
filter | Microsoft.Xrm.Sdk.Query.FilterExpression | FilterExpression in which to look for condition, typically myQuery.Criteria
|
attribute | System.String | Name of attribute on condition to return |
Iterated conditions on the filter itself, and any sub filter collections.
Innofactor.Xrm.Utils.Common.Misc
A class used to contain the sorting attributes for the comparer class.
Constructor of SortAttribute class. Takes an attribute name and an OrderType as arguments.
Name | Type | Description |
---|---|---|
attribute | System.String | The sort attribute |
type | Microsoft.Xrm.Sdk.Query.OrderType | The sort attribute sorting type (OrderType) |
Property returning the sort attribute.
The string that is the sort attribute.
Property returning the sorting type.
The OrderType value.