What you have above will work if you make FirstName and LastName
properties of EmpName rather than fields.
To make it work in
Silverlight, you must also do the following:
- Put EmpName in a class that is accessible both server- and client-side (e.g., put in in the web project, then add it as a link to the SharedCode folder in the Silverlight project).
- Either have your EmpName class implement IKnownType, or mark it with the [DiscoverableType(DiscoverableTypeMode.KnownType)] attribute. Doing either will enable DevForce to inform the serializer up front about your type so that it will serialize it properly when it encounters it.
- We also recommend that you attribute the class (EmpName) with the [DataContract] attribute, and each of its members with the [DataMember] attribute. Marking the type with the [DataContract] attribute means that only members marked with the [DataMember] attribute will be serialized; otherwise, the serializer will try to serialize all public members. There may be also other circumstances in which explicitly marking the type and its members with the DCS attributes will prevent trouble.
So here, for example, is what your EmpName class should look like:
[DataContract]
public class EmpName:IKnownType {
//public string FirstName, LastName; //must be properties!
[DataMember]
public string FirstName { get; set; }
[DataMember]
public string LastName { get; set; }
}
Edited by IdeaBlade - 01-Mar-2010 at 4:24pm