每当CRM上的任何实体都有更新时,除了ID之外,只将该实体的更新字段传递给相应的插件。我想从CRM中检索包含所有字段的实体。事实证明,我可以使用以下代码
来做到这一点IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
所以当我按如下方式检索实体时
service.Retrieve(entity.LogicalName, entity.Id, cols);
它返回数据类型“Entity”。如何更改它以说出联系人或帐户。 如果我使用这样的东西
service.Retrieve(entity.LogicalName, entity.Id, cols).ToEntity<contact>()
......它不承认联系。
任何想法??
答案 0 :(得分:0)
使用以下内容从实体中读取数据:
实体e = service.Retrieve(entity.LogicalName,entity.Id,cols); var x = e [&#39; attribute_to_read&#39;];
您必须输入转换数据。