我在Silverlight的RIA WCF服务的应用程序下面的代码域名服务:问题与Silverlight的
protected override void OnNavigatedTo(NavigationEventArgs e)
{
EmployeesService2 context = new EmployeesService2();
EntityQuery<Employee> query = context.GetEmployeeQuery();
context.Load(query);
int count = context.Employees.Count();
EmployeeGrid.ItemsSource = context.Employees;
}
它填充网格项目,但context.Employees.Count() = 0
。这是为什么?
另一个问题是,我有一个类似的代码针对另一个页面针对不同的域服务,其中 基于另一个实体模型和数据库。但在这种情况下,该服务没有返回任何实体。这可能是什么原因?数据库不是空的。
不,它不是... – Peter17 2011-03-22 15:40:43
Peter通过WCF RIA Services访问所有数据是异步的;你需要遵循的模式是使用上面的lambda方法或添加一个事件处理函数(我更喜欢lambdas)。 – 2011-03-22 18:24:15