Good day. I find the following code:
public class DocumentViewModel
{
/// <summary>
/// implicit model
/// </summary>
/// <param name="document"></param>
public static implicit operator DocumentViewModel(Document document)
{
return new Document
{
Id = document.Id,
};
}
}
It is used as follows:
DocumentViewModel results;
try
{
using (var context = new DbContext())
{
var uow = new DocumentUoW(context);
Document doc = uow.FindById(id);
results = doc; //aquí me da el StackOverFlowException
}
return Ok(results);
}
catch (Exception ex)
{
return BadRequest(ex.Message);
}
Calling the DocumentViewModel raises the following exception on the explicit cast:
System.StackOverflowException: 'Se produjo una excepción de tipo 'System.StackOverflowException'.'
The error does not show InnerException or StackTrace to trace, the debugger as soon as it gets there throws the error. I don't understand why it's happening, I'm trying to investigate but the error description is too generic to find anything to help me. Does anyone have an idea what's going on?