Missing data using wcf services RRS feed

  • Question

  • Hi,


    I developed an object, using LINQ to SQL, that represents my data structure.

    With a method I perform a query on records and I retrieve a set of item where, one of the fields is an entity ref to records inside another table, connected with a foreign key. I placed on this methods the datacontract attribute.

    When I launch this method I correctly see the set of records of the first table and, going down on the object tree, the set of record of the second table.

    Then I created a wcf service that should return the results of this method. When I try from a client it correctly returns records from the first table, the entity ref fields are there but without data inside, records from the second table are not present.

    What happens during wcf data serialization? I'm doing something wrong?

    Thursday, June 19, 2008 4:26 PM

All replies

  • Looks like a lazy loading issue. LINQ uses lazy loading so if you inspect your main object you'll see the data but just because they are loaded on demand under the hood.


    If you transmit the main object you won't see other values as they were not loaded...


    Try for example (I googled wcf Loadwith which is the option that allows to ask LINQ to load dependent data all along wiht the main data).





    Thursday, June 19, 2008 5:43 PM
  • Already done. Myabe I didn't explained well but linq correctly returns all the data. I changed the properties in order to have referenced entities loaded at the first time.

    Debugging I can see data returned from the linq query but when the wcf service pass this object to the client the referenced entities disappear.


    Friday, June 20, 2008 7:44 AM
  • HI,

    Have you found any solution to the problem because i am also facing the same problem. My WCF service is returning a list of customers(which is a entity class) of count 10. But my silverlight application is showing only the first member in the list.

    Paras Sharma
    Wednesday, May 4, 2011 2:07 PM
  • Hi,

    You need to apply the to those navigation properties.

    My understanding is that the idea is that in some cases, you may want to load some data server side (to perform whatever additional stuff you want) even if you don't need them client side. So you have to explicitely tell WCF which data loaded server side you'll need client side.

    Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".
    Wednesday, May 4, 2011 5:14 PM