address1_latitude и address1_longitude не получает от RetrieveMultiple

Привет, я пытался получить address1_latitude и address1_longitude из CRM, используя CRM SDK вот му код

var querybyattribute11 = new QueryByAttribute("account");
querybyattribute11.ColumnSet = new ColumnSet("name", "address1_city", "statuscode", "address1_postalcode", "address1_latitude", "address1_longitude");
querybyattribute11.Attributes.AddRange("name");
querybyattribute11.Values.AddRange("ASSOCIATED COMBUSTION INC");
EntityCollection entities = service.RetrieveMultiple(querybyattribute11);

foreach (Entity item in entities.Entities)
{

   // Console.WriteLine("Name: {0}. Id: {1}", role.Name, role.Id);
   list += item.Attributes["name"].ToString() + "  " + item.Attributes["address1_longitude"] .ToString() + "\n";
}

Но я не понимаю item.Attributes["address1_longitude"] сообщение об ошибке

'The given key was not present in the dictionary.'

1 ответ

Это может быть потому, что это ноль.

Попробуйте любой из этих 2 вариантов:

item["address1_longitude"]  (shouldn't raise exception, it would return null if blank, otherwise the address longitude)

Чтобы проверить, существует ли столбец:

item.Attributes.ContainsKey("address1_longitude")
Другие вопросы по тегам