|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace AccessStudy.Core
|
|
|
|
|
{
|
|
|
|
|
public class StudentServer
|
|
|
|
|
{
|
|
|
|
|
private OledbUtil dbUtil = new OledbUtil();
|
|
|
|
|
|
|
|
|
|
public List<Student> GetAll()
|
|
|
|
|
{
|
|
|
|
|
List<Student> students = new List<Student>();
|
|
|
|
|
|
|
|
|
|
var dataTable = dbUtil.GetDataTable("Student");
|
|
|
|
|
|
|
|
|
|
foreach (DataRow row in dataTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
var student = new Student()
|
|
|
|
|
{
|
|
|
|
|
Id = (int)row["Id"],
|
|
|
|
|
Name=row["Name"].ToString(),
|
|
|
|
|
Age = (int)row["Age"],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
students.Add(student);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return students;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|