Roman
Roman

Reputation: 4513

WCF and Linq 2 SQL

I'm trying to expose a simple WCF REST service using data from Linq to SQL.

The problem is when I have child objects (like a User object which has UserAction objects as children) - I get an empty result from the service. As it seems - the service it self is working and the data is being fetched from Linq as needed, but at the client side - no data is being shown.

If I delete all the child objects, it works just fine.

Any Ideas why this happens and how to fix?

EDIT: added the webservice code for that part

[WebGet(UriTemplate = "TopUpdaters/{topx}",
        ResponseFormat = System.ServiceModel.Web.WebMessageFormat.Json)]
public List<User> TopUpdaters(string topx)
{
   FulltankRepository rep = new FulltankRepository();
   var topusers = rep.GetTopUpdaters(int.Parse(topx));

   return topusers;
}

Thanks!

Upvotes: 0

Views: 252

Answers (1)

StuartLC
StuartLC

Reputation: 107247

If you've confirmed that the children exist in memory on the server, then it sounds like a serialization issue. Check that your UserAction property on User is marked for serialization

[DataMember]
public List<UserAction> UserActionChild
{
get;
set;
}

Upvotes: 1

Related Questions