如何使用 Silverlight 4.0 和 RIA 服务显示查找
我有一个关系数据库,可以说它由雇员表、部门表和雇员类型表组成。
员工表有一个 DepartmentId、EmployeeTypeId 外键
,现在我创建了一个带有实体数据模型的 silverlight 应用程序并生成了一个域服务类
,现在我想在网格中显示员工信息..当然我不能显示部门名称和网格中的 EmployeeType Name
我必须在元数据中使用 Include Data 注释..
我这样做了..但是如何在一个查询中显示所有包含的字段?
我使用了这个
public IQueryable<Employee> GetEmployeesWithDepartments()
{
return this.ObjectContext.Employees.Include("Department.EmployeesType");
}
,但我设法仅显示部门。其他外键怎么样?
如何将它们添加到我的查询中?
I have a relational database lets say it consist of an Employee's Table and Department's table and an EmployeesType Table.
The employee's table has a DepartmentId, EmployeeTypeId foreign Keys
and now I created a silverlight app with an entity data model and generated a domain service class
and now I want to show employees info in a grid .. of course I can't show Department name and EmployeeType Name in the Grid
I have to use the Include Data annotation in my metadata ..
I did this .. but how can I show all the included fields in one query?
I used this
public IQueryable<Employee> GetEmployeesWithDepartments()
{
return this.ObjectContext.Employees.Include("Department.EmployeesType");
}
but I managed to show departments only.. What About the other foreign keys?
How can I add them to my query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您绑定到 Employee 时 - 您可以访问 Department id,例如:
并且您可以访问 EmployeeType,例如
您问的是这个吗?
When you bind to Employee - you access Department id something like:
And you access EmployeeType like
Is that what you asking?
好吧,伙计们.. 经过两天的反复试验.. 我终于发现这
就是你应该做的..
在你的 getEmployees 方法或你使用的任何检索方法中,你可以包含所有外键,如下所示
等等对于您在元数据类中包含的每个伪造密钥
,那么在前端您现在可以访问 Department 属性并使用绑定语法将其与您的视图绑定,
如下所示:
感谢您的帮助
Ok guys .. so after two freaking days of trial and error .. i finally found it
here is what you should do ..
in your getEmployees Method or whatever method of retrival you use you can include all your forign keys as follow
and so on for every forgin key you have included in your metadata class
then in the front end you can now have access to the Department Property and use the Binding syntax to bind it with your View
as follow:
Thanks for trying to help