c# - 基于有序字符串列表的过滤对象c#
问题描述
我正在努力过滤从服务返回的数据,我在下面创建了一个虚拟示例。它们是否是仅选择传递到方法中的字段并以与字符串在列表中的相同顺序返回它们的有效方法。
返回所有值的方法一:
GetAll()
{
ServiceModelResult result = await GetAllFromDatabase();
return result;
}
方法二 - 我们以正确的顺序传入我们希望包含在返回模型中的字段的动态列表:
List<string> fieldsIWantToReturn = new List<string>("FirstName", "CustomerName", "Shop", "ExportPhase")
GetFilteredResults(List<string> fieldsIWantToReturn)
{
var result = await GetAllFromDatabase();
//This is the section I don't know how to do.
var filteredResults = //do something here to filter - only select the properties defined in the filter class & in the same order
return filteredResults;
}
解决方案
推荐阅读
- python - python3中使用for循环简化代码
- spring - Spring批处理如何知道文件是否完成写入
- mysql - MYSQL 定义器问题
- rest - NetSuite SuiteTalk REST Web 服务 - 登录尝试无效 - 沙盒帐户 ID 与 URL 中的帐户 ID
- javascript - 如果成员获得特定角色,我想添加货币但是如果成员具有该角色并获得另一个角色,它将再次给他们货币
- javascript - 插入数据库后更新 mobx 存储
- java - 有没有一种简单的方法来找到时间复杂度?
- angular - Ionic 5 Angular 9: Observable - 行为主体 - 状态管理
- asp.net-mvc - 如何保存对数据库所做的更改
- c - 为什么在给出 -pedantic 时,GCC 只抱怨与 %i 一起使用的 unsigned int 参数?