I am using the WCF REST service (GET method) to retrieve the POCO EF4. The service seems to be working fine. When I request uri in my browser, I get the results as expected.
In my client application, I am trying to use the HTTPExtension method for the WCF REST Starter Kit - ReadAsDataContract () to convert the result back to my POCO. This works great when the POCO navigation property is the only related POCO object. The problem is that the navigation property is a collection of related POCOs. The ReadAsDataContract () method throws an exception with the message "Object reference not installed in the object instance."
Below are my POCOs.
[DataContract(Namespace = "", Name = "Trip")] public class Trip { [DataMember(Order = 1)] public virtual int TripID { get; set; } [DataMember(Order = 2)] public virtual int RegionID { get; set; } [DataMember(Order = 3)] public virtual System.DateTime BookingDate { get; set; } [DataMember(Order = 4)] public virtual Region Region {
And this is how I try to get the POCO Region .
static void GetRegion() { string uri = "http://localhost:8080/TripService/Regions?id=1"; HttpClient client = new HttpClient(uri); using (HttpResponseMessage response = client.Get(uri)) { Region region; response.EnsureStatusIsSuccessful(); try { region = response.Content.ReadAsDataContract<Region>();
Would thank any pointers.
source share