为动态生成的属性添加属性

时间:2018-09-26 13:55:20

标签: c# .net properties attributes dynamics-crm

我正在尝试基于所选实体为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);

        }
    }

我的主要问题是如何向属性和泛型类型添加属性?

0 个答案:

没有答案