简体   繁体   中英

address1_latitude and address1_longitude is not getting from RetrieveMultiple

Hi i have tried to get address1_latitude and address1_longitude from CRM using CRM SDK here is mu code

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";
}

But I am not geting it item.Attributes["address1_longitude"] error message is

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

It might be because it's null.

Try either one of these 2 options:

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

To check if the column exists:

item.Attributes.ContainsKey("address1_longitude")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM