Linq to SQL从关系表中选择 [英] Linq to SQL selecting from relation table
问题描述
我有多个表,
I have, multiple tables,
division,
department,
group,
user
每个都有名称和ID
在另一个表(用户分组)中,我有
each of these have name and id
in another table(usergroupings) i have
userID
groupID
divisionID
departmentID
都是主表的外键
这会将用户ID链接到部门和组
现在使用Linq,我希望能够填充,
组名称等的组合框,
并将ID插入(usergroupings)
我可以在(用户组)中看到相关的表,
但不会用值填充组合框.
which are all foreign keys to the primary tables
this links a user id to a division department and group
now using Linq, i want to be able to populate,
a combo box with the group name etc,
and insert the id into(usergroupings)
I can see the relationed tables in (usergroupings),
but it does not populate the combo box with the values.
dbs = new dbConnDataContext();
var userGrouping =
from c in dbs.UserGroupings
select c;
推荐答案
按如下所示修改您的查询.
modify your query as below.
var userGrouping =
from c in dbs.UserGroupings
select c;
//Bind combobox after the making the list as below.
userGrouping.List();
有关更多信息,请参考下面的链接
LINQ to SQL [
for more please refer the below link
LINQ to SQL[^]
Hope this will help you.
这篇关于Linq to SQL从关系表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!