?
Solved

Entity Framework Model & WCF (Saving a Record)

Posted on 2011-09-06
4
Medium Priority
?
872 Views
Last Modified: 2012-05-12
I  am trying to convert JsonData into the object to save it into the database table using Entity framework model using the attached code. but ends up with the following error:

The type 'XXX"  cannot be serialized to JSON because its IsReference setting is 'True'. The JSON format does not support references because there is no standardized format for representing references. To enable serialization, disable the IsReference setting on the type or an appropriate parent class of the type.

The tableNameListData is:
String tableNameListData ="\"badges\":\"1\",\"notifications\":\"1\",\"sounds\":\"1\"}";

I am calling the attached code function in the following way:

  public string AddToTableNameList(string tableNameListData)
        {
            tableName ed = Deserialize<tablename>(tableNameListData); [Here isreference error comes]
            ----
            ---
        }

 
Please help!
public static T Deserialize<T>(string json) //
        {
            T obj = Activator.CreateInstance<T>();
            MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json));
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(obj.GetType());
            obj = (T)serializer.ReadObject(ms);
            ms.Close();
            return obj;
        }

Open in new window

0
Comment
Question by:Dinesh Kumar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Accepted Solution

by:
Dinesh Kumar earned 0 total points
ID: 36487793
In wcf method I wrote:
tableName objw = new tableName();    
JavaScriptSerializer serializer = new JavaScriptSerializer();  
objw = serializer.Deserialize<tableName>(tableJsonData);    


and i called it this way i.e modified the input data as follows:

String tableJsonData="{\"badges\":\"true\",\"notifications\":\"true\",\"sounds\":\"true\"}";

so if it is having corresponding int in the database table then the value say
\"id\":\"value\"
value should be integer e.g 4 or 5 etc. and not like 'din'

this way I was able to solve the issue.

also note true is not equal to 1 in c# so we need to write true only.

0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
ID: 37909725
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question