c# - 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?
解决方案
获取 ID 也更安全,因为您可以以无组织的顺序进行回复。
试图从索引数组中获取东西可能会导致错误,不仅是顺序错误,还有缺失值。
但仍然取决于您使用数据的服务的可靠性(以及您对它的了解程度)。
推荐阅读
- php - 有没有一种安全的方法可以将非公共方法用作信号处理程序?
- excel - 如何将单元格值分配给变量?
- c# - 加载子实体的 LINQ 方法,该子实体包括一些 Parent 的导航属性并且只选择了 Grand Child 的记录
- javascript - 在 JSON.parse 处获取“JSON 输入意外结束”
- android - Recycleview onclick如何切换到垂直和水平Linearlayoutmanager
- c - 如何将整数向下舍入到最接近的数字倍数?
- python-3.x - 掷骰子游戏输出错误信息
- java - 我在解密 java 中的字符串时遇到问题
- ios - AudioKit Recorder 示例因 iOS 的 EXC_BAD_ACCESS 而崩溃
- python - 从 Jupyter Notebook 下载图