Asp mvc 4 EF存储库

时间:2016-05-05 21:13:13

标签: c# entity-framework asp.net-mvc-4 repository

我有以下代码,我想知道如何从存储库中检索数据,这是我的代码,任何建议都会很感激,谢谢

我的控制器:

 namespace Diploma.WebUI.Controllers
 {
   public class StudentController : Controller
   {
     EfDbContext context = new EfDbContext();

     public ViewResult Student()
     {
        var student = context.Students.Include(p => p.Group);
        return View(student.ToList());
     }
   }
 }

我的存储库:

namespace Diploma.Domain.Concrete
{
 public class EFStudentRepository : IStudentRepository
 {
    EfDbContext context = new EfDbContext();

     public IEnumerable<Student> Students
     {
       get { throw new NotImplementedException(); }
     }

     public IEnumerable<Group> Groups
     {
       get { throw new NotImplementedException(); }
     }
  }

和我的抽象类

   namespace Diploma.Domain.Abstract
  {
     public interface IStudentRepository
     {
       IEnumerable<Student> Students { get;}
       IEnumerable<Group> Groups { get;} 
     }
  }

0 个答案:

没有答案