Используя MVC3, у меня есть хранилище Student (в проекте) и StudentService (в другом проекте).В сервисе я хочу создать функцию, которая возвращает всех студентов, которые находятся в таблице базы данных.Это новый способ для меня, поэтому я немного новичок.в функции GetAllStudents ниже, Как я могу изменить синтаксис для выбора всех.
В репозитории:
namespace SpeakOut.Data
{
public class StudentRepository
{
SpeakOutDataContext context;
private Table<StudentEntity> table;
public StudentRepository()
{
context = new SpeakOutDataContext();
table = context.GetTable<StudentEntity>();
}
public IQueryable<Student> Select()
{
return table.Select(x => new Student
{
WNumber = x.WNumber,
CatalogueYear = x.CatalogueYear,
Standing = x.Standing
});
}
}
}
В сервисах:
namespace SpeakOut.Services
{
public class StudentService
{
private StudentRepository repository;
public StudentService()
{
repository = new StudentRepository();
}
public IQueryable<Student> GetAllStudents()
{
return repository.Select().All(x => x.FirstName) ; //**This line is where I don't know how I would call all the students**
}
}
}