本文介绍了从API返回结果列表时出现异常错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在从.NET Core 3.X API返回数据,但始终收到此奇怪的错误:
I'm returning data from a .NET Core 3.X API but keep getting this strange error:
这是我在处理数据之前要做什么,然后立即将其返回.
Here is what I'm doing with the data before immediately returning it after.
var bookings = bookingData
.Select(x => new SpecialTaskVm(new TaskViewModel(x, null))
{
client = x.Client,
carer = x.Carer,
carer2 = x.Carer2
})
.ToList();
我尝试更改控制器方法类型
I have tried changing the controller method type
我希望数据能正常返回,而不是500错误
I expect the data to return normally rather than a 500 error
推荐答案
您的Client
和Carer
都通过ClientCarer
相互间接引用.
Your Client
and Carer
both have indirect references to each other via ClientCarer
.
我建议不要只用您需要的特定属性来创建新的类/匿名类型,而不要使用Client
和Carer
.
Rather than serving Client
and Carer
up I'd suggest creating a new class / anonymous type with just the specific properties you need.
这篇关于从API返回结果列表时出现异常错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!