Hi,
Whenever there is no value in the record, we don't get the attribute for that record. You can write a one common method and pass Entity and required attribute value. So that it could return the value.
public string GetValueFromEntity(Entity objEntity, string strAttriubtueName)
{
string strValue = string.Empty;
if (objEntity.Attributes.Contains(strAttriubtueName) && objEntity.Attributes[strAttriubtueName] != null)
{
strValue = objEntity.Attributes[strAttriubtueName].ToString();
}
return strValue;
}
you the above method in ForEach loop like below...
dr["description"] = GetValueFromEntity(entities, "description");
--
Thanks and Regards,
Gopinath.
http://mscrmtechie.blogspot.com