ASP.NET Core only returning first value of a collection in an entity

不问归期 提交于 2019-12-04 21:12:53

I had a similar issue, where only the first entity of the target collection was returned unless I was setting to null all the inner references.
However I was able to solve this by mapping my model to dto object (or ViewModel) before returning it. The dto has usually a subset of the model entity. In this way I did not have to set to null the inner references.

In general I think it is a good practice to return to the client only the properties that are strictly needed, without giving the whole model object.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!