When I am linking annotations to a specific entity, rather than creating a relationship like so:
var associateRequest = new AssociateRequest
{
Target = new EntityReference(SalesOrder.EntityLogicalName, salesOrderGuid),
RelatedEntities = new EntityReferenceCollection
{
new EntityReference(Annotation.EntityLogicalName, noteGuid),
},
Relationship = new Relationship("SalesOrder_Annotation")
};
Is it possible to reference the relationship in a strongly typed way:
var associateRequest = new AssociateRequest
{
Target = new EntityReference(SalesOrder.EntityLogicalName, salesOrderGuid),
RelatedEntities = new EntityReferenceCollection
{
new EntityReference(Annotation.EntityLogicalName, noteGuid)
},
Relationship = SalesOrder.Relationships.SalesOrder_Annotation // <----- ???
};
This would be similar to being able to get the logicalname at develop time:
SalesOrder.EntityLogicalName
Can we reference the specific 1:N relationship the same way:
SalesOrder.Relationships.SalesOrder_Annotation
SalesOrder.Relationships.SalesOrder_Annotation
? If it isn'tRelationship
then no, you can't call it. I have to ask becauseSalesOrder.Relationships.SalesOrder_Annotation
isn't available using the standard CrmSvcUtil.exe code gen tool - so it much be something custom. – Plowmanconst
orreadonly
strings with the relationship names. Or write a method to read the relationship name from the code attribute outputted byCrmSvcUtil.exe
. – Plowman