我正在创建临时报告解决方案,因此我想出了一个此方法,将其添加到 WCF 服务中,该服务将从前端客户端调用,
GetEmployeeDetails(int id, bool includeAddressHistory, bool includeSalaryHistory, bool includePositionHistory, bool includeProjectHistory, ...never ending list)
现在的问题是我需要根据过滤器获取所有数据,然后返回完整的数据集或将其作为流返回,因为我有另一种方法可以返回与流相同的数据集,
最佳答案
通常,当您需要传递相当大量的参数(无论其类型如何)时,就应该考虑 parameter object :
// this is just POCO
public class SearchParameters
{
public string SomeString { get; set; }
public DateTime? SomeDate { get; set; }
public bool? SomeBool { get; set; }
// etc...
}
IEnumerable<SomeEntitites> GetSomeEntitites(SearchParameters searchParameters);
请注意,对于构造函数情况,解决方案可以是构建器模式。
关于c# - 我应该避免几个 bool 参数吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35170758/