public StudentModel GetDetails(int studentEnrollmentNumber) { SqlConnection studentRecord = new SqlConnection(_connectionString); string cmd = string.Format("SELECT * FROM state join StudentDetails on ( state.StateId = StudentDetails.StateId) join Streams on (StudentDetails.StreamId = Streams.StreamId) WHERE EnrollmentNumber = {0} ", studentEnrollmentNumber); SqlCommand command = new SqlCommand(cmd, studentRecord); studentRecord.Open(); SqlDataReader readerObject = command.ExecuteReader(); if (readerObject.Read()) { _studentModel = new StudentModel(); _studentModel.EnrollmentNumber = Convert.ToInt32(readerObject["EnrollmentNumber"]); _studentModel.Name = (string)readerObject["Name"]; _studentModel.State = (string)readerObject["StateName"]; _studentModel.Stream = (string)readerObject["Stream"]; _studentModel.StateId = Convert.ToInt32(readerObject["StateId"]); _studentModel.StreamId = Convert.ToInt32(readerObject["StreamId"]); return _studentModel; } return null; }
public void GetDetails(int studentEnrollmentNumber) { _studentModel = _studentDBService.GetDetails(studentEnrollmentNumber); if (_studentModel != null) { //Student storeValue = new Student(); this._enrollmentNumber = _studentModel.EnrollmentNumber; this._name = _studentModel.Name; this._marks = _studentModel.Marks; this._streamId = _studentModel.StreamId; this._stateId = _studentModel.StateId; this._state = _studentModel.State; this._stream = _studentModel.Stream; } }