I am attempting to pull an IQueryable from my DomainService class to my XAML code behind using RIA services.
The DomainService pulls from a BLL, which pulls from a DAL, which gets it from EF.
I cannot seem to access the foreign table in the XAML, but I can access it just fine in the DomainService method.
The DomainService method looks like this...
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;
}
In the XAML code behind, I call this method here:
...
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
};
...
How can I get this table up to my XAML code so I can databind to it?
The problem here was that my Entity Model is not a part of my ASP.Net/RIA app. It is only referenced in.
Since it is a reference, the DomainService won't auto-generate the metadata. I had to manually create the metadata so that Silverlight knew what to expect.