locked
URL Query Projection in WCF Data Service RRS feed

  • Question

  • Hi,

    I cannot figure out how to get a URL REST Query to project only the properties I need from the parent entity and its child collection.

    This is what I have tried but to no avail.

    http://localhost:2332/LabellerDataService.svc/SiteClients(21)?$expand=SiteClientMailings&$select=SiteID,ClientID,ClientName,ClientMailingID,JobReference,ClientName  

    Please note that the first 3 properties should come from the parent object (SiteClients(21)) -  SiteID,ClientID,ClientName

    and the last 3 should come from the child collection (SiteClientMailings) - ClientMailingID,JobReference,ClientName 

    This works but it returns all properties:

    http://localhost:2332/LabellerDataService.svc/SiteClients(21)

    <d:SiteClientID m:type="Edm.Int32">21</d:SiteClientID>
      <d:SiteID m:type="Edm.Int32">354</d:SiteID>
      <d:ClientID m:type="Edm.Int32">354</d:ClientID>
      <d:ClientCode>1010</d:ClientCode>
      <d:ClientRef>101</d:ClientRef>
      <d:ClientName>CITIPOST client</d:ClientName>
      <d:ActiveFlag m:type="Edm.Byte">1</d:ActiveFlag>
      <d:TimeStamp m:type="Edm.DateTime">2006-03-28T00:03:38</d:TimeStamp>
      <d:ForceExport m:type="Edm.Boolean" m:null="true" />

    And this works but it returns all properties

    http://localhost:2332/LabellerDataService.svc/SiteClients(21)?$expand=SiteClientMailings

      <link rel="edit" title="SiteClientMailing" href="SiteClientMailings(1486)" />
      <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/SiteClient" type="application/atom+xml;type=entry" title="SiteClient" href="SiteClientMailings(1486)/SiteClient" />
      <category term="DocketHubModel.SiteClientMailing" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    - <content type="application/xml">
    - <m:properties>
      <d:ClientMailingID m:type="Edm.Int32">1486</d:ClientMailingID>
      <d:CarrierID m:type="Edm.Int32">354</d:CarrierID>
      <d:SiteClientID m:type="Edm.Int32">21</d:SiteClientID>
      <d:JobReference>BM0117_r1</d:JobReference>
      <d:JobCode />
      <d:JobDescription>BM0117_r1</d:JobDescription>
      <d:PlannedMailingDate m:type="Edm.DateTime">2007-02-04T00:00:00</d:PlannedMailingDate>
      <d:MailingStatus m:type="Edm.Byte">6</d:MailingStatus>
      <d:ActiveFlag m:type="Edm.Byte">0</d:ActiveFlag>
      <d:Segments m:type="Edm.Byte">1</d:Segments>
      <d:ClientName>CITIPOST client</d:ClientName>
      <d:PriceStatus m:type="Edm.Byte" m:null="true" />
      <d:SupplierPrice m:type="Edm.Double" m:null="true" />
      <d:CarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:TotalPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneASupplierPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneACarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneATotalPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneBSupplierPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneBCarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneBTotalPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneCSupplierPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneCCarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneCTotalPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneDSupplierPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneDCarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneDTotalPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneESupplierPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneECarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneETotalPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneZSupplierPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneZCarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:ZoneZTotalPrice m:type="Edm.Double" m:null="true" />
      <d:GrandTotalSupplierPrice m:type="Edm.Double" m:null="true" />
      <d:GrandTotalCarrierMarkupPrice m:type="Edm.Double" m:null="true" />
      <d:GrandTotalPrice m:type="Edm.Double" m:null="true" />
      <d:TotalItemsForMailing m:type="Edm.Int32">15051</d:TotalItemsForMailing>
      <d:EstimatedBagCount m:type="Edm.Int32">0</d:EstimatedBagCount>
      <d:TotalSSCCount m:type="Edm.Int32">0</d:TotalSSCCount>
      <d:Timestamp m:type="Edm.DateTime">2007-01-16T13:36:26.73</d:Timestamp>
      <d:AverageItemWeight m:type="Edm.Double">22</d:AverageItemWeight>
      <d:PrintStatus m:type="Edm.Int32" m:null="true" />
      <d:PrintCurrentSSC m:null="true" />
      <d:PrintItemsInSSC m:type="Edm.Int32" m:null="true" />
      <d:PrintItemsToDate m:type="Edm.Int32" m:null="true" />
      <d:RegionCode m:null="true" />
      <d:PreviousMailingStatus m:type="Edm.Int32" m:null="true" />
      <d:FileUploadID m:type="Edm.Int32" m:null="true" />
      <d:PrimaryServiceID m:type="Edm.Int32">7</d:PrimaryServiceID>
      <d:ProcessState m:type="Edm.Int32" m:null="true" />
      <d:Process m:type="Edm.Int32" m:null="true" />
      <d:ForceExport m:type="Edm.Byte" m:null="true" />
      <d:ImportOptionID m:type="Edm.Int32" m:null="true" />
      <d:ImportHandler m:type="Edm.Byte" m:null="true" />
      <d:MinorStatus m:type="Edm.Byte" m:null="true" />
      <d:MinorProgress m:type="Edm.Byte" m:null="true" />
      <d:NextActivity m:type="Edm.Byte" m:null="true" />
      <d:ProcessRows m:type="Edm.Int32" m:null="true" />
      <d:ItemsDirect m:type="Edm.Int32" m:null="true" />
      <d:ItemsResidue m:type="Edm.Int32" m:null="true" />
      <d:ItemsUnsorted m:type="Edm.Int32" m:null="true" />
      <d:ItemsReject m:type="Edm.Int32" m:null="true" />
      <d:ForecastType m:type="Edm.Byte" m:null="true" />
      <d:ForecastSplit m:type="Edm.Byte" m:null="true" />
      <d:SubClientID m:type="Edm.Int32" m:null="true" />
      <d:ClientCode1 m:null="true" />
      <d:ClientCode1ID m:type="Edm.Int32" m:null="true" />
      <d:ClientCode2 m:null="true" />
      <d:ClientCode2ID m:type="Edm.Int32" m:null="true" />
      <d:ClientCode3 m:null="true" />
      <d:ClientCode3ID m:type="Edm.Int32" m:null="true" />
      <d:ClientCode4 m:null="true" />
      <d:ClientCode4ID m:type="Edm.Int32" m:null="true" />
      <d:MasterClientMailingID m:type="Edm.Int32" m:null="true" />
      <d:ParentClientMailingID m:type="Edm.Int32" m:null="true" />
      <d:DefaultContainerTypeID m:type="Edm.Int32">1</d:DefaultContainerTypeID>
      <d:Advised m:type="Edm.Boolean" m:null="true" />
      <d:PostfixCode>AEJ</d:PostfixCode>
      </m:properties>
      </content>

    Cheers

    Claudio

    Thursday, March 22, 2012 12:54 PM

Answers

All replies