Solved

Entity Framework Model & WCF (Saving a Record)

Posted on 2011-09-06
4
864 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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