3

我有这个代码:

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 对象中的属性?

4

1 回答 1

2

您需要引用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;
            }
        }
    }
}
于 2012-06-19T13:39:19.647 回答