c# - Serialization in Entities -


hi have following entity

employee --------- emp_id report_id last_name first_name ----------navigation properties employee1 employee2 

it has foreign key relation same table emp_id , report_id

when run webapi created keep getting error   <message>an error has occurred.</message> <exceptionmessage> 'objectcontent`1' type failed serialize response body content type 'application/xml; charset=utf-8'. </exceptionmessage> <exceptiontype>system.invalidoperationexception</exceptiontype> <stacktrace/> <innerexception> <message>an error has occurred.</message> <exceptionmessage> object graph type 'cm.entities.employee' contains cycles , cannot serialized if reference tracking disabled. </exceptionmessage> <exceptiontype> system.runtime.serialization.serializationexception </exceptiontype> 

spent alot of time on cant seem figure out how shake off error. please help.

you need add [datacontract(isreference = true)] employee class.

[datacontract(isreference = true)]  [serializable] public class employee {    /* ... properties */ } 

reference on msdn


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -