Passing a large number of parameters in 3 tier architecture in asp.net website project

StackOverflow https://stackoverflow.com/questions/13170920

  •  24-07-2021
  •  | 
  •  

문제

I have just started to implement application development using 3-tier architecture. Also I am following some good coding practices. In the application, I need to pass some large amount of data to save(around 20 parameters) the student details. But as Good programming practice says,"Do not pass more than 5 parameters in a function. if you have to pass more then use objects to pass data as a single entity".

How should I pass this large amount of data from presentation layer to the DAL?

도움이 되었습니까?

해결책

Create a property class of student and use its object as parameter like

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

and create an instance of CStudentProps like this

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

and then call the function

addStudent(CStudentProps  ob);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top