我正在尝试基于所选实体为Microsoft Dynamics 365开发多用途自定义工作流,并且对于每个实体,我都希望动态地生成其属性的几个字段
这是属性表
[Input("created on")]
[Output("created on")]
public InOutArgument<DateTimeOffset> createdon
{
get { return createdon; }
set { createdon = value; }
}
这是我尝试生成它的方式。
public void generateEntityFields()
{
RetrieveEntityRequest req = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = _crmWorkflowContext.WorkflowExecutionContext.PrimaryEntityName
};
RetrieveEntityResponse res = (RetrieveEntityResponse)_crmWorkflowContext.OrganizationService.Execute(req);
EntityMetadata currentEntity = res.EntityMetadata;
foreach (AttributeMetadata attribute in currentEntity.Attributes)
{
var property = new ExpandoObject() as IDictionary<string, Object>;
property.Add(attribute.LogicalName, string.Empty);
}
}
我的主要问题是如何向属性和泛型类型添加属性?