c# - 具有大量参数的 DAL 方法

标签 c# methods parameters

我的 DAL 中有几个方法,带有相当多的参数:

public Collection<Proforma> SearchAllProforma(DateTime? startDate = null, DateTime? endDate = null,
        int? institutionID = null, int? inspectionID = null, bool? isFollowup = null, bool? excludeDeleted = null,
        bool? nutritionalOnly = null, int? parentInspectionID = null)

我应该将它们压缩以获取对象参数吗?或者让它们保持原样,使用可选参数?或者两者兼而有之?

编辑 - 我真的应该说,这些参数中的每一个都映射到存储过程的一个参数。

最佳答案

我建议您为所有这些参数创建一个类作为属性。

然后将类作为参数发送。

Class SerachAllProformaParameter
{
//All Properties.
}

SerachAllProformaParameter parameter= new SerachAllProformaParameter();
parameter.PropertyName="value";

public Collection<RoIVProforma> SearchAllProforma(parameter);

关于c# - 具有大量参数的 DAL 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10734411/

相关文章:

java - 单击 OnBindViewholder recyclerview android 中的监听器

javascript - 以另一个函数作为参数调用的函数,不能完全理解它的概念

swift - 通用类型参数作为变量

c# - 如何让一个方法接受不确定数量的不同类型的列表?

c# - 登录页面和MySqlDataReader异常错误

c# - XBAP 中的键盘快捷键

python - 类型错误 : method() takes 1 positional argument but 2 were given

javascript - 如果我将要查找的值设置为变量,为什么它不起作用?

c - 在 C 中调用函数之前的参数评估顺序

c# - 如何通过*多个*连接限制/限制带宽