在asp.net网站项目中传递3层架构中的大量参数

时间:2012-11-01 04:23:09

标签: asp.net 3-tier

我刚刚开始使用3层架构实现应用程序开发。此外,我正在遵循一些良好的编码实践。在应用程序中,我需要传递一些大量数据来保存(大约20个参数)学生的详细信息。但正如良好的编程实践所说,“不要在函数中传递超过5个参数。如果你必须传递更多,那么使用对象将数据作为单个实体传递”。

如何将大量数据从表示层传递到DAL?

1 个答案:

答案 0 :(得分:0)

创建学生的属性类,并将其对象用作参数,如

 [Serializable]
public class CStudentProps
{
    public String StudentID { get; set; }
    public String StudentName { get; set; }
    public String StudentEmailID { get; set; }
    public String Status { get; set; }
    ...
    ...
}

并创建一个像这样的CStudentProps实例

CStudentProps student=new CStudentProps()
student.name="";
.....
.....

然后调用函数

addStudent(CStudentProps  ob);
相关问题