string fetch = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='true'>
<entity name='hnny_class'>
<attribute name='hnny_classid' />
<attribute name='hnny_name' />
<attribute name='createdon' />
<order attribute='hnny_name' descending='false' />
<link-entity name='hnny_class_opportunity' from='hnny_classid' to='hnny_classid' visible='false' intersect='true'>
<link-entity name='opportunity' from='opportunityid' to='opportunityid' alias='aa'>
<filter type='and'>
<condition attribute='opportunityid' operator='eq' uiname='' uitype='opportunity' value='" + initialRelatedEntity.Id + "' />";
fetch+=@"</filter>
</link-entity>
</link-entity>
</entity>
</fetch>";
FetchExpression exep = new FetchExpression(fetch);
EntityCollection collection = service.RetrieveMultiple(exep);
// throw new Exception("Count"+collection.TotalRecordCount);
if (collection.Entities.Count > 0)
{
string classNames = "";
foreach (Entity classes in collection.Entities)
{
if (classNames == "")
classNames = classes.Attributes.Contains("hnny_name") ? (String)classes["hnny_name"] : string.Empty;
else
classNames += classes.Attributes.Contains("hnny_name") ? (String)classes["hnny_name"] : string.Empty;
}
Entity opp = new Entity("opportunity", new Guid("{C2A03262-E8B8-E911-A961-000D3A12468B}"));
opp["hnny_classes"] = classNames; // use classfiled logcal name
service.Update(opp);
}
*This post is locked for comments