1

我正在尝试根据 SdkMessageProcessingStepImageId 的值选择 SdkMessageProcessingStepId 属性,请参见下面的 xml,但我很挣扎。

<SdkMessageProcessingStep Name="Plugins.OnPreCreateUpdateCar: Update of new_car" SdkMessageProcessingStepId="{00c19595-76fd-e111-9528-005056af005a}">
  <PluginTypeName>Plugins.OnPreCreateUpdateCar, Plugins, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f59c17e3653dba0</PluginTypeName>
  <PrimaryEntity>new_car</PrimaryEntity>
  <AsyncAutoDelete>0</AsyncAutoDelete>
  <InvocationSource>1</InvocationSource>
  <Mode>0</Mode>
  <Rank>1</Rank>
  <SdkMessageId>{20bebb1b-ea3e-db11-86a7-000a3a5473e8}</SdkMessageId>
  <EventHandlerTypeCode>4602</EventHandlerTypeCode>
  <Stage>20</Stage>
  <IsCustomizable>1</IsCustomizable>
  <IsHidden>0</IsHidden>
  <SupportedDeployment>0</SupportedDeployment>
  <SdkMessageProcessingStepImages>
    <SdkMessageProcessingStepImage Name="PreImageCar">
      <SdkMessageProcessingStepImageId>{e3c5bcb1-76fd-e111-9528-005056af005a}</SdkMessageProcessingStepImageId>
      <EntityAlias>PreImageCar</EntityAlias>
      <ImageType>0</ImageType>
      <MessagePropertyName>Target</MessagePropertyName>
      <IsCustomizable>1</IsCustomizable>
    </SdkMessageProcessingStepImage>
  </SdkMessageProcessingStepImages>
</SdkMessageProcessingStep>

我尝试了各种方法,例如两个查询、连接,但似乎没有任何效果。最后我选择了一个完全不同的解决方案,但是知道如何在一个查询中执行此操作会很方便。

TIA

4

1 回答 1

1

我不确定你想要达到什么目的。但也许这会有所帮助:

 XElement xmlTree = XElement.Load(source);

 string[] result = xmlTree.Descendants("SdkMessageProcessingStepImageId")
                .Where(element => element.Value == "{e3c5bcb1-76fd-e111-9528-005056af005a}")
                .Select(element => element.Parent.Parent.Parent)
                .Attributes()
                .Where(attribute => attribute.Name == "SdkMessageProcessingStepId")
                .Select(attribute => attribute.Value)
                .ToArray();

结果:

{00c19595-76fd-e111-9528-005056af005a}
于 2012-09-13T19:27:55.597 回答