首页 > 解决方案 > Is it a good strategy to return data list from a method (API) without ID and later bind this data list to main list by array Index ID?

问题描述

I have a simple doubt.

Let me explain.

I have an employee List. The joining date info of these employees are to be got from an API.

So I select the list of EmpIds from this employee List and pass it to the API to retrieve list of date of joining.

Now, is it a good approach to return only the date List from the API without the ID, so that I can bind it to the main List using array Index. Or should I return both the id and the dates? And bind using the ID of the employee?

标签: c#arrayslistapidata-structures

解决方案


获取 ID 也更安全,因为您可以以无组织的顺序进行回复。

试图从索引数组中获取东西可能会导致错误,不仅是顺序错误,还有缺失值。

但仍然取决于您使用数据的服务的可靠性(以及您对它的了解程度)。


推荐阅读