Search code examples
c#wcfsubsonicwcf-clientdatacontract

Missing object properties from a WCF service with SubSonic?


I have written a basic WCF service that uses SubSonic for data retrieval.

After publishing the service I am consuming it in a C# application. When calling the method that uses that SubSonic query, I get back the right number of objects from the database, but none of them contain the database properties and their values. It looks like only SubSonic properties.

The SubSonic DAL is contained in a separate project that is referenced in the WCF service project.

WCF service interface:

   [OperationContract]
   GeoLocationCollection GetGeoLocations(long websiteID);

Worker method:

    public GeoLocationCollection GetWebsiteGeoLocations(long websiteID)
    {
        GeoLocationCollection locationsCollection = new Select()
                                .Where(GeoLocation.Columns.WebsiteID).IsEqualTo(1)
                                .From(GeoLocation.Schema)
                                .ExecuteAsCollection<GeoLocationCollection>();
        return locationsCollection;
    }

Both the GeoLocationCollection and GeoLocation have been automatically decorated with [Serializable].

The service is consumed as follows:

MyService.MyServiceClient client = new MyService.MyServiceClient();
var result = client.GetWebsiteGeoLocations(1);

foreach (MyService.GeoLocation location in result)
{
    // do stuff
}

So once again, why can I not see any of my actual table properties/values in location?


Solution

  • WCF services require [DataContract] + [DataMember] attribute and not [Serializable]. This maybe the reason for you to not get the attribute values.