Click here to Skip to main content
Click here to Skip to main content
Alternative Article

Tagged as

Go to top

REST with WCF and Entity Framework with JSON Serialization

, 1 May 2013
Rate this:
Please Sign up or sign in to vote.
This is an alternative for "REST with WCF and Entity Framework with JSON Serialization"

Note : This is an alternate solution for  This Article.

Alternate Solution for JSON Serialization

You can use Json.NET library to serialize Entity FrameWork object. It is fast and more effective then given solution. JavascriptSerialization but it is taking more time then Json.NET.

You can find source code from : http://json.codeplex.com/

Simple Example  

 using (FrameworkContainer fc = new FrameworkContainer()) //Entity Framework Object
            {
                var realObject = fc.GetAccountInformation("AmitGajjar"); // Calling Entity Framework Function (SP)

                using (MemoryStream ms = new MemoryStream())
                {
                    var result = from account in realObject
                                 select new
                                 {
                                     Name = account.Account_Name,
                                     City = account.Address1_City,
                                     Phone = account.Address1_Telephone
                                 };
// serializedObject will be json object from entity
                    var serializedObject = JsonConvert.SerializeObject(result);
                }
            } 

Hope this will help you to implement serialization very quickly.  

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

@AmitGajjar
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140921.1 | Last Updated 2 May 2013
Article Copyright 2013 by @AmitGajjar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid