修改函数以返回所有记录 [英] Modfying a Function to return all records
问题描述
如何修改此功能以返回所有记录? 我已经在这方面工作了两天但没有成功。 我在实体框架中加载了一个视图,显示每个员工的教育,注册,语言等等。 我需要
函数来返回所有行,甚至是重复的员工ID。
我还需要在另一个网格中选择employeeId并让此查询的结果显示所有教育另一个网格中的员工,注册,语言......等。
提前谢谢。
公共函数GetEmpHistDetail()作为IQueryable(Of EmpHistDetails_vw)
返回Me.ObjectContext.EmpHistDetails_vw.OrderBy(函数(e)e.Emp)
结束函数
数据库视图也被视为EF中的实体。
因此,如果视图实体具有相同的实体键,则EF会将它们视为单个实体而不是两个不同的实体。
为了实现您的请求,我建议您在视图实体中设置更多实体密钥,而不是仅将员工ID标记为实体密钥,以便检索到的
数据将显示不同的数据,即使它们具有重复的员工ID。
美好的一天!
< span style ="font-family:Calibri">
最好的问候,b
Lingzhi Sun
MSDN订阅者支持
在论坛
如果您对我们的支持有任何反馈,请联系
msdnmg@microsoft.com
How can I modify this function to return all records? I have been working on this for two days with no success. I loaded a view in the entity framework that displays education, registration, languages..etc that each employee has. I need the function to return all rows, even duplicate employee ID's.
I also need to select employeeId in another grid and have the results of this query display all education, registrations, languages...etc for the employee in another grid.
Thank you in advance.
Public Function GetEmpHistDetail() As IQueryable(Of EmpHistDetails_vw) Return Me.ObjectContext.EmpHistDetails_vw.OrderBy(Function(e) e.Emp) End Function
Hi,
Database views are also treated as entities in EF. So if the view entities have the same entity key, EF treats them as the single one entity instead of two different ones.
To realize your request, I would recommend you set more entity keys in the view entity instead of just marking the employee ID as the entity key, so that the retrieved data will show different data even they have duplicate employee ID.
Good day!
Best Regards,
Lingzhi SunMSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
这篇关于修改函数以返回所有记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!