Using MVC3, I have a student repository (in a project) and StudentService (in another project). In the service, I want to create a function that returns all students that are in the db table. This is a new way to do something for me, so I'm a little newbie. in the GetAllStudents function below, How can I change the syntax to select everything.
In the repository:
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 }); } }
}
In services:
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) ;
}
source share