I have two lists from which I have to get two values(MyCaption and 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 I am directly getting from one of the list. Now to get MyValue I need to find based on otherUserField.FieldName.
i.e I have to find myUserFields.FieldName which is equal to otherUserField.FieldName and assign it to MyValue.
Can it be done in the single query which is as above? Please suggest
1 Answer