I have a for loop that selects some fields using RetrieveMultiple service method, like below:
QueryExpression query2 =newQueryExpression("contact"); query2.ColumnSet.AddColumns("address1_line1"); query2.ColumnSet.AddColumns("address1_line2"); query2.ColumnSet.AddColumns("address1_freighttermscode"); query2.ColumnSet.AddColumns("mobilephone"); query2.ColumnSet.AddColumns("emailaddress1");var x2 = _orgService.RetrieveMultiple(query2);foreach(var entityItem in x2.Entities){Entity testAccount = entityItem;...code here to pass testAccount variable variable to another method to process the row...}
Then I compare the fields of "entityItem" specifically "firstname" and "lastname" to another collection from my own table.
The problem is some fields in CRM have null values.
1) if a field has a null value, will it totally remove the attribute from the properties of the row? So the above code,
if the "mobilephone" is NULL, will the attribute "mobilephone" be removed by the service method in the attribute list?
2) how do i handle the null when trying to access the field like this
testAccount.Attributes["mobilephone"].ToString()
without doing this?
var temp = testAccount.Attributes["mobilephone"].ToString() ? String.Empty : testAccount.Attributes["mobilephone"].ToString()