0

Why do I get compilation errors from the following?

int[] threadIDs = { 4,5,6,7,8,9,10,11,12,13,14,15,16,17 }; CSDataContext db = new CSDataContext(); var posts = from p in db.cs_Posts, t in threadIDs where p.ThreadID == t select p.ThreadID; 
1
  • 1
    It'd be helpful to see the compilation error. Commented Oct 15, 2009 at 23:29

2 Answers 2

6

What are you trying to do? Select all posts that have thread IDs in the list?

Then something like this would work

int[] threadIDs = {4,5,6,7,8,9,10,11,12,13,14,15,16,17}; CSDataContext db = new CSDataContext(); var posts = from p in db.cs_Posts where threadIds.Contains(p.ThreadID) select p.ThreadID; 
Sign up to request clarification or add additional context in comments.

Comments

2

Did you Try

var posts = from p in db.cs_Posts from t in threadIDs where p.ThreadID == t select p.ThreadID; 

Leave out the comma and add another 'from'

2 Comments

This won't work if it is linq to sql, as is tagged in the question.
Your answer got rid of my compilation errors but as John Gietzen mentioned, it wont work if it is in linq to sql. Nice try and thanks!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.