【发布时间】:2010-11-11 21:14:08
【问题描述】:
我正在尝试使用 RIA 服务将 IQueryable 从我的 DomainService 类中提取到我的 XAML 代码中。
DomainService 从 BLL 中提取,从 DAL 中提取,从 EF 中获取。
我似乎无法访问 XAML 中的外部表,但我可以在 DomainService 方法中正常访问它。
DomainService 方法如下所示...
public IQueryable<MenuHeader> GetMenuHeaders()
{
BusinessLogic.Employee blEmployee = new BusinessLogic.Employee();
int employeeId = blEmployee.GetEmployeeIdFromUserName(HttpContext.Current.User.Identity.Name);
var menuHeaders = blEmployee.GetEmployeeMenuHeaders(employeeId);
// This works here!
var menuHeaderItems = from mh in menuHeaders
select mh.MenuHeaderItems;
return menuHeaders;
}
在后面的 XAML 代码中,我在这里调用了这个方法:
...
EmployeeContext employeeContext = new EmployeeContext();
EntitySet<MenuHeader> menuHeaders = employeeContext.MenuHeaders;
employeeContext.Load(employeeContext.GetMenuHeadersQuery()).Completed += (s, e) =>
{
// This does NOT work here!
var menuHeaderItems = from mh in menuHeaders
select mh.MenuHeaderItems; // <-- Not found
};
...
如何将这个表添加到我的 XAML 代码,以便我可以对其进行数据绑定?
【问题讨论】:
标签: silverlight entity-framework ria domainservices