Ria Services:如何从服务器调用方法?

时间:2018-11-29 11:49:32

标签: c# silverlight mvvm viewmodel wcf-ria-services

这些天,我开始研究我的第一个Silverlight MVVM应用程序。 我开始了解事物是如何工作的,而我的第一个方法是:

我通过以下方法获得了StudentDomainService:

 public IQueryable<Student> GetStudents()
    {
        return _studentRepository.GetStudents().AsQueryable();
    }

然后,在StudentViewModel中,我有以下代码:

 public StudentViewModel()
    {
        _studentDomainContext = new StudentDomainContext();
        _studentDomainContext.Load(_studentDomainContext.GetStudentsQuery());
     }

  public EntitySet<Student> Students
    {
        get { return _studentDomainContext.Students; }
    }

我使用Students属性来绑定到StudentsView中的DataGrid。而且一切正常。当我启动该应用程序时,网格中出现了我的3个学生。

但是现在我有任务来更改StudentDomainService中的方法。有人告诉我使用IEnumerable而不是IQueryable,所以现在我的StudentDomainService是这样的:

public IEnumerable<Student> GetStudents()
    {
        return _studentRepository.GetStudents();
    }

但是问题是我现在不知道要在ViewModel中做什么,因为显然我不能使用GetStudentsQuery()或EntitySet,而且我不知道如何以这种方式绑定到数据网格

感谢您的帮助,在此先感谢您!

0 个答案:

没有答案