我的 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/