I want to convert this query syntax to method syntax, silly but confused
List<int> x = new List<int>();
// code to fill list
from ug in DataContext.UserGroups
where (
from f in x
select f
).Contains(ug.ID)
select ug;
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
var results = DataContext.UserGroups.Where(ug => x.Contains(ug.ID)).Select(ug => ug.ID);I think that’s what you want. The code you put in your question wasn’t 100% complete. Were you just trying to get the IDs of
UserGroupsthat were in the int list? If you just want theUserGroupsthat match, remove the.Selectpart of my query.To get the
UserGroupsthat match:var results = DataContext.UserGroups.Where(ug => x.Contains(ug.ID));