如何从插件类型项中检索步骤



我有这段代码:

foreach (PluginAssembly tempPluginAssembly in pluginAssemblyList)
            {
                if (!tempPluginAssembly.Name.StartsWith("Microsoft.Crm"))
                {
                    List<PluginType> pluginList;
                    pluginList = xrmContext.PluginTypeSet.Where(Plugin => Plugin.PluginAssemblyId.Id == tempPluginAssembly.Id).ToList();
                    foreach (PluginType plugin in pluginList)
                    {
                        if (plugin.IsWorkflowActivity == false)
                        {
                            writer.WriteLine(new string[] { tempPluginAssembly.Name, tempPluginAssembly.Description, plugin.Name, String.Empty });
                            ++pluginCount;
                        }
                    }
                }
            }

基本上,它的作用是从我的crm环境中检索程序集列表并过滤Microsoft程序集。然后,我检索这些程序集中包含的每个 PluginType 对象,并将信息记录在某处。但这还不够,我想检索每个 PluginType 对象中包含的步骤。

我该如何管理?是否有我不知道的类或 PluginType 对象中的属性我不知道?

您需要引用SdkMessageProcessingStep实体来检索插件步骤。您可以在下面的代码中看到查询中的联接。

foreach (PluginAssembly tempPluginAssembly in pluginAssemblyList)
{
    if (!tempPluginAssembly.Name.StartsWith("Microsoft.Crm"))
    {
        var pluginList = from plugins in xrmContext.PluginTypeSet
                         join steps in xrmContext.SdkMessageProcessingStepSet on plugins.PluginTypeId equals steps.PluginTypeId.Id
                         where plugins.PluginAssemblyId.Id == tempPluginAssembly.Id
                         select new
                         {
                             plugins,
                             steps
                         };

        //_XrmContext.PluginTypeSet.Where(Plugin => Plugin.PluginAssemblyId.Id == tempPluginAssembly.Id).ToList();
        foreach (var plugin_step in pluginList)
        {
            if (plugin_step.plugins.IsWorkflowActivity == false)
            {
                writer.WriteLine(new string[] { tempPluginAssembly.Name, tempPluginAssembly.Description, plugin_step.plugins.Name, String.Empty });
                ++pluginCount;
            }
        }
    }
}

最新更新