根据另一个 LINQ 到实体查询的结果更新一个实体
我有以下 LINQ-to-Entities 查询:
' Get all the residency assignments that match the term/year.
Dim assignments = From p In dbContext.Residents _
Where p.semester = term _
Where p.year = year _
Select p
这将为我提供当前年份/学期的所有驻留分配。然后我有这个 LINQ-to-Entities 查询:
Dim reset_occupancy = From p In dbContext.Rooms _
Select p
这将为我提供所有房间。我想迭代分配并根据分配的房间更新重置占用率中的占用率。我不是 100% 确定如何实现这一点。这是我想要完成的伪代码:
For each row in assignments
reset_occupancy.Where(reset_occupancy.room=assignment.occupancy).current_occupancy =+1
Next
I have the following LINQ-to-Entities query:
' Get all the residency assignments that match the term/year.
Dim assignments = From p In dbContext.Residents _
Where p.semester = term _
Where p.year = year _
Select p
This will give me all the resident assignments for the current year/term. Then I have this LINQ-to-Entities query:
Dim reset_occupancy = From p In dbContext.Rooms _
Select p
This will give me all the rooms. I want to iterate through the assignments and based on what room is assigned update the occupancy in reset_occupancy. I'm not 100% sure how to accomplish this. Here is my pseudo code of what I want to accomplish:
For each row in assignments
reset_occupancy.Where(reset_occupancy.room=assignment.occupancy).current_occupancy =+1
Next
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果有人有更好的答案,我仍然喜欢它......但对于其他尝试类似过程的人来说,我是如何解决它的:
If someone has a better answer, I'd still like it...but for anyone else trying a similar process here is how I resolved it: