views:

95

answers:

2
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json)]
public List<DataModal.Employee> GetCustomers()

I want to return list of employee which is Entity Model object type. How they can be serialize by default or need to write some code. I am using jquery.

+1  A: 

You need to put [DataContract] attributes on your entity classes, and [DataMember] attributes on every property or field you want to have serialized. That's the standard way of doing thing in WCF. Once you do that, you can serialize your List<Employee> across a WCF service call.

marc_s
+1  A: 

Are you using Entity Framework 4 POCO objects? If not I do not think that this is going to work, or altleast not work well.

I would recommend that you create Data Transfer Objects marked with DataContract and DataMember, then use auto mapper to map the objects.

Shiraz Bhaiji