views:

30

answers:

0

I have 2 classes: Person and Contact.

Person class has a property named ContactNumber which returns the Contact type, and this property is marked as a DataMember for serialization. I have marked Contact type as a DataContract.

On the client side I am able to get the values, but when I try to insert a value and then do submit, I get the following exception:

Failed to deserialize change-set. Failed to convert value of type 'Dictionary`2' to type 'Contact'

Stack Trace is:

at System.Web.Ria.DataServiceSubmitRequest.GetChangeSet(DomainService domainService) at System.Web.Ria.DataServiceSubmitRequest.Invoke(DomainService domainService) at System.Web.Ria.DataService.System.Web.IHttpHandler.ProcessRequest(HttpContext context)

Can anyone give me the solution ?

I am just trying with this code, when i want to do insert it throws the exception written above. this is for POCO sample i am trying. code is listed below:

[DataContract]
public class Person
{
    [datamember]
    public int Age;
    [datamember]
    public string Email;
    [datamember]
    public string FirstName;
    [Key]
    public int Id;
    [datamember]
    public string LastName;
    [datamember]
    public int PhoneNumber;
    [datamember]
    public Contact ContactNumber;
}

[DataConrtact]
public class Contact
{
    int num;

    [DataMember]
    [Key]
    public int Number
    {
        get { return num; }
        set { num=value; }
    }
}

Actually, both are marked as DataContract, and properties as well with Datamember attribute.

Person class is generatd from EDM Entity model. and i want to have custom property with it, which is Contact type. How should i do it ?