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
Post a Comment