none
Navigation properties are not materialized on the client side RRS feed

  • Question

  • In a Silverlight application that consumes data using WCF with endpoint httpbinding I get a list of main entities (ie. Customers) with related secondary entities (ie. Orders) using INCLUDE.

    On the server side this code works fine, and the web service that returns data to the client side built in Silverlight I can see my main entities and their secondary, INCLUDE has worked correctly.

    If I use a session of fiddler2 I can see as the service returns the SOAP message xml perfectly (the main entities and their secondary entities)

    However the client side on Silverlight ONLY MATERIALIZE THE PRIMARY ENTITIES (customers) the secunadarias (orders) not them materialized.

    When built the Web reference marked the option to "Reuse the types of the following assemblies" marking just the assemblies containing the definitions of my entities EOF. The namespaces in the part client and server are the same. The attribute "Knowntype" is used in all primary and secondary entitites.

    Could someone help me with this issue?

    Many thanks in advance.

    Julio Trujillo Leon. Microsoft Certified Professional Developer. .NET Developer and TFS admin. . Please, if my contribution is useful for you press on "useful button" Por favor, si les ha sido útil pulsen en "el mensaje ha sido útil" https://www.mcpvirtualbusinesscard.com/VBCServer/JulioTrujilloLeon/interactivecard
    Thursday, January 12, 2012 9:15 AM

Answers

  • Fix.


    Proxies generator embedded in VS2010 works well when on the server side the EF model and all its infrastructure if is located in only one an Assembly and only one namespace as the part client in Silverlight, which should be in a single Assembly (all the Self Tracking entities and other kinds of infrastructure) and under a single name space. If you don't follow these guidelines, do not materialize 2nd level entities, in addition that the proxy generator sometimes fails and generates the proxy empty.

    Julio Trujillo Leon. Microsoft Certified Professional Developer.
    Tuesday, January 31, 2012 4:10 PM

All replies

  • Hi Julio,

    Welcome!

    To tell you truth, I'm not familiar with Silverlight, but I think if you include the secondary entities, it should appear on client in your query. I think you can refer this link: http://msdn.microsoft.com/en-us/library/ee789839(VS.100).aspx

    ---------------------------------------

     public List<Department> GetDepartments()
        {
            using (SchoolEntities context = new SchoolEntities())
            {
                // Use System.Data.Objects.ObjectQuery(T).Include to eagrly load the related courses.
                return context.Departments.Include("Courses").OrderBy(d => d.Name).ToList();
            }
        }

     

    ---------------------------------------

    Here is example: http://archive.msdn.microsoft.com/EFDocSamples2010, I think you can test the sample to see if it works.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, January 13, 2012 3:51 AM
    Moderator
  • Hi Alan

    First of all, thanks for your time.

    The situation is a little more complex that you are understood by my explanation.

    VS2010 Shells a utilty proxy executable that generates code in a structure of files and folders to manage comunication between consumer and provider parts. When you consume a WCF service, your code access the web service across this proxy.

    Proxy generated works fine, but when you have an principal and secondary entitties (using "Include" to acess from principal to secondary) the server return them for client part ok, but the materializing in the client side fails generating only primary entities (the secondary are empty).

    Bye


    Julio Trujillo Leon. Microsoft Certified Professional Developer.
    Friday, January 13, 2012 4:19 PM
  • Hi Julio,

    Thanks for your feedback.

    I think you can try to use $expand in client query: http://blogs.msdn.com/b/marcelolr/archive/2008/12/01/depth-vs-width-in-ado-net-data-services-expand.aspx

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 16, 2012 7:40 AM
    Moderator
  • Hi,

    I am writing to check the status of the issue on your side.Would you mind letting us know the result of the suggestions?

    If you need further assistance, please feel free to let me know.I will be more than happy to be of assistance.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, January 18, 2012 2:54 AM
    Moderator
  • Fix.


    Proxies generator embedded in VS2010 works well when on the server side the EF model and all its infrastructure if is located in only one an Assembly and only one namespace as the part client in Silverlight, which should be in a single Assembly (all the Self Tracking entities and other kinds of infrastructure) and under a single name space. If you don't follow these guidelines, do not materialize 2nd level entities, in addition that the proxy generator sometimes fails and generates the proxy empty.

    Julio Trujillo Leon. Microsoft Certified Professional Developer.
    Tuesday, January 31, 2012 4:10 PM