0

I have been browsing through answers on stackoverflow for this problem and people wrote about disabling lazyloading and disabling proxycreation. But it did not help. Here is my code.

        public ActionResult GetBooks()
    {
        using (DatabaseContext db = new DatabaseContext())
        {
            db.Configuration.LazyLoadingEnabled = false;
            db.Configuration.ProxyCreationEnabled = false;
            var ksiazki = (from b in db.books join a in db.authors on b.fk_author_id equals a.author_id select new { b, a }).ToList();

            return Json(ksiazki, JsonRequestBehavior.AllowGet);
        } 
    }

When I try to enter url /x/GetBooks, I got the serialization error for the entity model of books

aceofbassgreg
  • 3,837
  • 2
  • 32
  • 42
Harugawa
  • 539
  • 5
  • 19
  • You can use a library like Newtonsoft Json or FastJson to do the json serialization for you...check the accepted answer here: http://stackoverflow.com/questions/9110724/serializing-a-list-to-json – Hackerman Oct 26 '16 at 16:16
  • Just return an anonymous object containing only those properties you need in the client. –  Oct 26 '16 at 21:29

0 Answers0