c# - "Circular Reference" exception when serializing database object -


I get an error stating that circular references were detected while serializing the type of object I believe that I have something with the database and I have a set of PK and FK. Public string GetSongs (int playlistId) {var songs = (_db.Songs by song where song.PlaylistId == playlistlist select song). List (); Var serializer = new JavaScriptSerializer (); Var json = serializer.Serialize (song); // error message here json back; }

Here is a picture of my DB schema:

Enter image details here

If you are using the code first playlist model and playlist to song in the user keyword by keyword . Because playlist load your user model automatically and your playlist is user and loop is turned on .

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -