[英]Azure Mobile Service with .NET Backend get exception
When adding an entity with a child entity (1:n) I'm getting an exception. 当添加带有子实体(1:n)的实体时,出现异常。 I can only get this exception when the debugger is catching all exceptions. 当调试器捕获所有异常时,我只能获取此异常。 Unfortunately only the message of the exception is visible and not the exception itself with the information I need. 不幸的是,只有异常的消息是可见的,而异常本身以及我所需要的信息却不可见。 (System.Data.Entity.Validation.DbEntityValidationException) (when inserting an entity without childs the service works correct) (System.Data.Entity.Validation.DbEntityValidationException)(当插入不带子项的实体时,服务正常工作)
The client gets a MobileServiceInvalidOperationException: The request could not be completed. 客户端获取MobileServiceInvalidOperationException:请求无法完成。 (Bad Request) (错误的请求)
The method on the controller (PatchAppointment) is the only method where I can add exceptionhandling and the exception is not coming in here. 控制器上的方法(PatchAppointment)是我可以添加异常处理的唯一方法,并且这里没有异常。
public Task<Appointment> PatchAppointment(string id, Delta<Appointment> patch)
{
try
{
return UpdateAsync(id, patch);
}
catch (Exception ex)
{
// not coming through here..
throw;
}
}
I also tried adding an ExceptionLogger to the Httpconfiguration.Services but no exception is coming in. 我还尝试将ExceptionLogger添加到Httpconfiguration.Services中,但没有例外。
How should I get the whole exception object to see the EntityValidationErrors? 我应该如何获取整个异常对象以查看EntityValidationErrors? When this is known I can also add logging when exceptions occur. 如果知道这一点,我也可以在发生异常时添加日志记录。
What do you mean by "PatchAppointment in the only method" that you can add exception handling? 您可以添加异常处理的“唯一方法中的PatchAppointment”是什么意思? If you have trouble inserting you have to check PostAppointment not PatchAppointment. 如果您在插入时遇到麻烦,则必须检查PostAppointment而不是PatchAppointment。 PatchAppointment deals with updating data while you mentioned that you have trouble inserting into your table. 当您提到无法插入表时,PatchAppointment处理更新数据。
public async Task<IHttpActionResult> PostAppointment(Appointment item)
{
Appointment current = await InsertAsync(item);
return CreatedAtRoute("Tables", new { id = current.Id }, current);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.