对您的问题的最短回答是在数据库中查询实体引用指出(引用)的实体。我一直将实体引用视为(粗略)等同于 C++ 中的指针。它有它的地址(guid),但你需要取消引用它才能找到蜂蜜。你这样做是这样的。
IOrganizationService organization = ...;
EntityReference reference = ...;
Entity entity = organization.Retrieve(reference.LogicalName, reference.Id,
new ColumnSet("field_1", "field_2", ..., "field_z"));
当我进行大量从EntityReference到Entity的转换时,我部署了带有可选参数的扩展方法。
public static Entity ActualEntity(this EntityReference reference,
IOrganizationService organization, String[] fields = null)
{
if (fields == null)
return organization.Retrieve(reference.LogicalName, reference.Id,
new ColumnSet(true));
return organization.Retrieve(reference.LogicalName, reference.Id,
new ColumnSet(fields));
}
You can read more and compare EntityReference and Entity.