问题描述
你好我有三个数据库表:
用户(UserID,FirstName,LastName)
客户端(ClientID,Name)
用户客户端(UserClientID) ,UserID,Name)
如果我在上下文中有用户,如何检索其相关的UserClient记录及其相关的客户记录?
我可以轻松加载UserClient记录如下:
CurrentUser.UserClients.Load();
然后逐个循环它们以加载它们相关的客户记录,但这是很多前往数据库。
我希望能够一次性加载UserClients和客户。
提前谢谢你,
克雷格
Howdy
I have three database tables:
Users (UserID, FirstName, LastName)
Clients (ClientID, Name)
UserClients (UserClientID, UserID, Name)
If I have a User in context, how do I retrieve its related UserClient records as well as their related Client record?
I can easily load the UserClient records like so:
CurrentUser.UserClients.Load();
and then cycle through them one at a time to load their related Client record, but that's a lot of trips to the database.
I'd like to be able to load both UserClients and Clients in one go.
Thankyou in Advance,
Craig
推荐答案
这篇关于如何加载相关的实体集合及其自己的相关实体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!