我有一个 CRM 函数,它返回实体中所有属性的属性类型。我的问题是,尽管过去同样的方法也有效,但现在无论我传递给它的实体如何,它都会抛出这个错误。
尝试反序列化参数时出错http://schemas.microsoft.com/xrm/2011/Contracts/Services:ExecuteResult
这是我的代码,我正在传递“帐户”实体。
public string GetFieldType(IOrganizationService svc, string entity, string fieldName)
{
RetrieveEntityRequest request = new RetrieveEntityRequest()
{
EntityFilters = EntityFilters.Attributes,
LogicalName = entity
};
RetrieveEntityResponse response = (RetrieveEntityResponse)svc.Execute(request);
string type = "";
foreach (AttributeMetadata attribute in response.EntityMetadata.Attributes)
{
if (attribute.LogicalName == fieldName)
{ type = attribute.AttributeType.ToString(); }
}
return type;
}