如何从PluginType项检索Step

时间:2012-06-19 13:10:26

标签: c# dynamics-crm dynamics-crm-2011

我有这段代码:

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环境中检索程序集,并过滤微软程序集。然后,我检索这些程序集中包含的每个PluginType对象,并在某处记录信息。但这还不够,我想检索每个PluginType对象中包含的步骤。

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

1 个答案:

答案 0 :(得分: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;
            }
        }
    }
}