I expose a complex type through OData. The class is like this:
public class RemoteFile
{
[Key]
public int Id { get; set; }
[Required]
public string Resource { get; set; }
public virtual ICollection<RemoteFile> RelatedFiles { get; set; }
}
And I expose it through OData:
var modelBuilder = new ODataConventionModelBuilder();
modelBuilder.ComplexType<RemoteFile>();
Here is what I got when I start the project:
An exception of type 'System.ArgumentException' occurred in System.Web.Http.OData.dll but was not handled in user code
Additional information: The complex type 'RemoteFile' has a reference to itself through the property 'RelatedFiles'. A recursive loop of complex types is not allowed.
If there is a handler for this exception, the program may be safely continued.
Any suggestion is welcomed.