TFS OData工作项获取最后一个插入id

TFS OData工作项获取最后一个插入id,tfs,odata,Tfs,Odata,我正在使用TFS OData服务创建工作项,该工作项工作正常。现在我需要得到工作项的id,并插入到数据库中供以后参考。有人能为我指明这方面的方向吗 以下是我得到的回应 <?xml version="1.0" encoding="utf-8" standalone="yes"?> <entry xml:base="https://tfsodata.visualstudio.com/DefaultCollection/" xmlns:d="http://schemas.mic

我正在使用TFS OData服务创建工作项,该工作项工作正常。现在我需要得到工作项的id,并插入到数据库中供以后参考。有人能为我指明这方面的方向吗

以下是我得到的回应

   <?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="https://tfsodata.visualstudio.com/DefaultCollection/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:etag="W/&quot;datetime'2013-08-31T10%3A23%3A21.1439028%2B00%3A00'&quot;" xmlns="http://www.w3.org/2005/Atom">
  <id>https://tfsodata.visualstudio.com/DefaultCollection/WorkItems(0)</id>
  <title type="text">my test work item</title>
  <summary type="text">test work item created by isuru http://www.google.com</summary>
  <updated>2013-08-31T10:23:21Z</updated>
  <author>
    <name />
  </author>
  <link rel="edit" title="WorkItem" href="WorkItems(0)" />
  <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="WorkItems(0)/Attachments" />
  <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Links" type="application/atom+xml;type=feed" title="Links" href="WorkItems(0)/Links" />
  <category term="Microsoft.Samples.DPE.ODataTFS.Model.Entities.WorkItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
  <content type="application/xml">
    <m:properties>
      <d:Id m:type="Edm.Int32">0</d:Id>
      <d:Project>My Website</d:Project>
      <d:Type>Product Backlog Item</d:Type>
      <d:WebEditorUrl m:null="true" />
      <d:AreaPath m:null="true" />
      <d:IterationPath m:null="true" />
      <d:Revision m:type="Edm.Int32">0</d:Revision>
      <d:Priority m:null="true" />
      <d:Severity m:null="true" />
      <d:StackRank m:type="Edm.Double">0</d:StackRank>
      <d:AssignedTo m:null="true" />
      <d:CreatedDate m:type="Edm.DateTime">2013-08-31T10:23:21.1419032+00:00</d:CreatedDate>
      <d:CreatedBy m:null="true" />
      <d:ChangedDate m:type="Edm.DateTime">2013-08-31T10:23:21.1439028+00:00</d:ChangedDate>
      <d:ChangedBy m:null="true" />
      <d:ResolvedBy m:null="true" />
      <d:Title>my test work item</d:Title>
      <d:State m:null="true" />
      <d:Reason m:null="true" />
      <d:CompletedWork m:type="Edm.Double">0</d:CompletedWork>
      <d:RemainingWork m:type="Edm.Double">0</d:RemainingWork>
      <d:Description>test work item created by isuru http://www.google.com</d:Description>
      <d:ReproSteps m:null="true" />
      <d:FoundInBuild m:null="true" />
      <d:IntegratedInBuild m:null="true" />
      <d:AttachedFileCount m:type="Edm.Int32">0</d:AttachedFileCount>
      <d:HyperLinkCount m:type="Edm.Int32">0</d:HyperLinkCount>
      <d:RelatedLinkCount m:type="Edm.Int32">0</d:RelatedLinkCount>
      <d:Risk m:null="true" />
      <d:StoryPoints m:type="Edm.Double">0</d:StoryPoints>
      <d:OriginalEstimate m:type="Edm.Double">0</d:OriginalEstimate>
      <d:BacklogPriority m:type="Edm.Double">0</d:BacklogPriority>
      <d:BusinessValue m:type="Edm.Int32">0</d:BusinessValue>
      <d:Effort m:type="Edm.Double">0</d:Effort>
      <d:Blocked m:null="true" />
      <d:Size m:type="Edm.Double">0</d:Size>
    </m:properties>
  </content>
</entry>

我所做的是将Guid添加到您不使用的随机场,然后查询该Guid

        wi.Title = "New Work Item";
        wi.FoundInBuild = Guid.NewGuid().ToString();
        wi.Type = "Bug";
        wi.Project = "TestProject";

        context.AddToWorkItems(wi);
        context.SaveChanges();
        Debug.WriteLine(String.Format("Work item created"));

        var createdWi = context.WorkItems.Where( d => d.FoundInBuild == wi.FoundInBuild);