【发布时间】:2012-01-19 12:50:03
【问题描述】:
我有两个列表,我必须从中获取两个值(MyCaption 和 MyValue)。
List<UserInfoModel> userInfo = new List<UserInfoModel>();
List<myuser_field> myUserFields = GetMyUserFields();
var otherUserFields = otherUserService.GetOtherUserFields();
userInfo = (from otherUserField in otherUserFields
where otherUserField.Chosen == true
select new UserInfoModel {
MyCaption = otherUserField.FieldAlias,
MyValue =
}).ToList();
MyCaption 我直接从列表之一中获取。现在要获取 MyValue,我需要根据 otherUserField.FieldName 查找。 即我必须找到等于 otherUserField.FieldName 的 myUserFields.FieldName 并将其分配给 MyValue。
可以在上面的单个查询中完成吗?请推荐
【问题讨论】:
-
您可以使用两个集合的连接:weblogs.asp.net/rajbk/archive/2010/03/12/…