|
|
#1 |
|
Участник
|
Вопрос по EntityCollection
В продолжении предыдущей темы
хотелось бы у вас коллеги проконсультироваться вот по какому вопросу: в своем коде : Код: Entity phonecall = service.Retrieve("phonecall", entity.Id, new ColumnSet(true));
if (phonecall.Attributes.Contains("regardingobjectid"))
{
EntityReference regarding = (EntityReference)phonecall.Attributes["regardingobjectid"];
if (regarding.LogicalName == "lead")
{
Entity lead = service.Retrieve("lead", regarding.Id, new ColumnSet(true));
EntityReference companyname = (EntityReference)lead.Attributes["new_companyname"];
Entity account = service.Retrieve("account", companyname.Id, new ColumnSet(true));
string name = account.Attributes["name"].ToString();
phonecall.Attributes.Add("new_nameofaccount", name);
service.Update(phonecall);
return;
}
if (regarding.LogicalName == "account")
{
Entity account = service.Retrieve("account", regarding.Id, new ColumnSet(true));
string name = account.Attributes["name"].ToString();
phonecall.Attributes.Add("new_nameofaccount", name);
service.Update(phonecall);
return;
}
if (regarding.LogicalName == "campaignactivity")
{
if (entity.Attributes.Contains("to"))
{
foreach (Entity acc in ((EntityCollection)entity.Attributes["to"]).Entities)
{
string name = service.Retrieve("account", acc.Id, new ColumnSet(true)).ToString();
phonecall.Attributes.Add("new_nameofaccount", name);
service.Update(phonecall);
}
return;
}
}Все таки каким способом необходимо получить значение сущности из этого поля? За ранее известно что там (Всегда!!!) будет одна сущность. За ранее спасибо!!! |
|
|