I am working on an appliction, using Entity Framework 4.0. and WCF.
I am returning list of objects say (Employees)
and the navigational property of that object is say(Departments)
and Department has further a navigational property (Branch)
I am including everything as
Employees.include("Departments.Branch");
Now th issue all those departments whose Branch is same, is set to null(except the first one) upon deserializing on WCF.
I need to use the branch for some binding purposes, kindly guide me how should i get rid of this problem.
This is the screenshot of the entities
It may be that the data is not being loaded before serialisation, but when you debug on the server side, lazy loading causes the data to be loaded.
A couple of things that you could try.
This will force the query to run:
Employees.include("Departments.Branch").ToList();
This will explicitly load the entities:
context.Entry(Employees).Reference(u => u.Departments.Branch).Load();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With