Linq to Entities change of behavior with WCF? RRS feed

  • Question

  • I have a problem that looks very strange.

    The behavior of my Linq to Entities query is not the same if I call it from a WCF webservice or from a Console application. Both the projects use .NET Framework 4.5 and Entity Framework is in version 5.0.

    Here is my Linq query:

    List<Training> trainings = (from t in context.Trainings
                                            from c in context.Chapters
                                            where == c.id_training
                                            orderby t.creation_date
                                            select t).Skip(0).Take(x)

    When used with the console project, the Navigation Property is working and I can see the Chapters contained in a Training.

    When used with the WCF project, the Navigation Property tells me that no Chapter exist for the same Training...

    I also tried to use a join instead of using a double from query.

    If I use the following query, WCF sends me an error when I try to access to the service operation.

    List<Training> trainings = (from t in context.Trainings.Include("Chapters")
                                            orderby t.creation_date
                                            select t).Skip(0).Take(x)

    Error : "An error occurred while receiving the HTTP response to http://localhost:35219/Service.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details."

    I am a little bit stuck on this one, any help is greatly appreciated.



    -- Update

    I have just tried to re-generate my DbContext but I still face the same issue.

    • Edited by linvỉ Thursday, November 22, 2012 3:31 AM
    Thursday, November 22, 2012 2:36 AM