4.10 Deleting an Entity

This example illustrates how a user can delete an Entity in the metadata store.

The example assumes that the preceding example has been successfully executed.

The following actions are carried out:

  1. The user requests the protocol client to delete Entity with the name "Buyer" and the namespace "example.com".

  2. The protocol client calls the Delete method as shown in the following code segment:

     BDCServiceReference.BusinessDataCatalogSharedServiceClient myClient = new BDCServiceReference.BusinessDataCatalogSharedServiceClient();
    
    // /***** Any implementation-specific impersonation logic goes here *****/
    
     BDCServiceReference.EntityStruct myEntity = new BDCServiceReference.EntityStruct();
     System.Version ver = new Version(1, 1);
      
     Guid myPartition = new Guid("00000000-0000-0000-0000-000000000000");
      
     myEntity = myClient.GetEntityWithNameAndNamespace("example.com", "Buyer", myPartition);
     myClient.Delete(myEntity);
    
  3. The protocol server checks if the Entity exists in the Metadata store.

  4. If it exists, the protocol server deletes the Entity from the Metadata store.

Request body

 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
     <Delete xmlns="http://www.microsoft.com/Office/2009/BusinessDataCatalog">
       <metadataObjectStruct i:type="a:EntityStruct" xmlns:a="Microsoft.SharePoint.BusinessData" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
         <a:id>135</a:id>
         <a:isCached>true</a:isCached>
         <a:name>Buyer</a:name>
         <a:objectVersion>3</a:objectVersion>
         <a:partitionId>00000000-0000-0000-0000-000000000000</a:partitionId>
         <a:active>true</a:active>
         <a:lobSystemId>122</a:lobSystemId>
         <a:modelId>0</a:modelId>
         <a:namespace>example.com</a:namespace>
         <a:version xmlns:b="http://schemas.datacontract.org/2004/07/System">
           <b:_Build>0</b:_Build>
           <b:_Major>1</b:_Major>
           <b:_Minor>0</b:_Minor>
           <b:_Revision>0</b:_Revision>
         </a:version>
         <a:cacheUsage>Default</a:cacheUsage>
         <a:description i:nil="true"/>
         <a:estimatedInstanceCount>100</a:estimatedInstanceCount>
       </metadataObjectStruct>
     </Delete>
   </s:Body>
 </s:Envelope>

Response body

 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Body>
     <DeleteResponse xmlns="http://www.microsoft.com/Office/2009/BusinessDataCatalog"/>
   </s:Body>
 </s:Envelope>