Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8565281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:23:26+00:00 2026-06-11T17:23:26+00:00

I have a WCF service Operation, I’d like it to return an object graph

  • 0

I have a WCF service Operation, I’d like it to return an object graph rather than a simple list of objects. Is there some magic LinQ to do this?

Thanks

A bit more info is possibly needed:

I have a couple of entities:

StockableItem
+ Id
+ Code

Stock
+ Id
+ Location
+ Qty

StockableItem->Stock is a 1..* relationship.

and I am failing with this linq:

from si in svc.StockableItems.Include(“Stock”)
join s in svc.Stock on si.Id equals s.Id
where s.Location == 1
select si

and several variations.

I’m hoping the service operation will be able to return something like this:

StockableItem – ID=213, Code=xxx
StockableItem – ID=214, Code=xxx2
    + Stock – ID=214, Location=1, Qty=3
StockableItem – ID=215, Code=xxx3
StockableItem – ID=216, Code=xxx4
    + Stock – ID=216, Location=1, Qty=6

i.e. To return all StockableItems along with the Stock entries for the given location. It’s pretty much just a left outer join:

Select * from StockableItems si
Left outer join Stock s ON si.Id = s.Id and s.Location = @Location

but turned into an object graph.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:23:27+00:00Added an answer on June 11, 2026 at 5:23 pm

    It’s not entirely clear; sounds like you’d ideally want an OData solution. You can’t return an object graph from a WCF Data services service operation called from an OData query. You can get a flat list of objects but then need to use $expand to get the object graph. In your case $expand won’t work, it’ll return all the stock instances for whichever StockItems pass the filter.

    I think your best bet would be to create a view in your DB (I assume you have a table of locations?)

        SELECT       si.Id, Locations.Location 
        FROM         StockableItem AS si  
        CROSS JOIN   Locations
    

    In your entity model, add this view as an entity (called XXX say) and set up navigation properties between it and your StockableItem and Stock entities.

    Now you can run OData queries like

    .../XXX?$expand=StockableItem,Stock&$filter=isof(Stock,'YourModelName.Stock') and Location eq 1
    

    It’s not the exact object graph you were after but, unless you want to start adding links client side, it’s the best you’re going to get.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service where I am trying to return a List (where
I have a WCF Service operation which takes an object as a parameter. This
I have a WCF service which performs CRUD operation on my data model: Add,
I have a wcf service defined like this: [OperationContract] [WebInvoke(Method = POST, ResponseFormat =
I have a WCF service that can return large amount of data depending on
I have a WCF service hosted in IIS6. It is doing simple WebRequest. When
I have a WCF service with an operation contract that returns null values. That
I'm working on a WCF Service. I have one service operation Function getValues(Optional verbose
I have a wcf restful service with a operation contract that contains two values
I have a WCF service with this declared operation: [WebGet(UriTemplate = Test/{*testString})] public String

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.