![](/img/trans.png)
[英]An entity with the same identity already exists in this EntitySet. - WCF RIA Services
[英]WCF RIA Services, EntitySet always empty?
关于新的WCF Ria服务beta的一个简短问题:
如果我在后面的代码中这样做:
EntitySet e = MyContext.Employees
似乎在运行时,entityset总是为空? 即,如果我想遍历Employee实体集。
另外,如果获取实体集的枚举数,则会收到一条错误消息,告诉我该枚举数为空或尚未启动。 是否有任何方法可以从上下文中获取实体集合并对其进行迭代?
提前致谢!
您是否已在“ 完成的事件”回调中进行检查? 请记住,在Silverlight中,所有调用都是异步的。 即使您在回调之前看到在其中分配ItemsSource的示例代码,也依赖于Employees是用于数据绑定的ObservableCollection的事实。
LoadEmployeeCommand()
{
// The Load method initiates the call to the server
LoadOperation<Employee> loadOperation = domainContext.Load(domainContext.GetEmployeesQuery());
// The EntitySet is still empty at this point
employeeDataGrid.ItemsSource = domainContext.Employees;
loadOperation.Completed += EmployeeLoadOperationCompleted;
}
private void EmployeeLoadOperationCompleted(object sender, EventArgs e)
{
// Don't need to reassign now but at this point the collection should be populated
employeeDataGrid.ItemsSource = domainContext.Employees;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.