Beispiel #1
0
 public List <Students> GetIndividualStudents(string studentName)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(SqlDataAccessConnection.connect("SchoolApp")))
     {
         var results = connection.Query <Students>("GetIndividualStudents @StudentName", new { StudentName = studentName }).ToList();
         return(results);
     }
 }
Beispiel #2
0
        public List <Students> GetStudentWithMarks()
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(SqlDataAccessConnection.connect("SchoolApp")))
            {
                var results = connection.Query <Students>("GetStudentsWithMarks").ToList();

                return(results);
            }
        }
Beispiel #3
0
 //I used Dapper framework to connect sql server
 public List <Students> GetStudents()
 {
     //The using namespace makes sure you don't live connection to the server open.
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(SqlDataAccessConnection.connect("SchoolApp")))
     {
         var results = connection.Query <Students>("GetAllStudents").ToList();
         return(results);
     }
 }