tags:

views:

72

answers:

2

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;
+2  A: 

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'

Shankar Ramachandran
This won't work if it is linq to sql, as is tagged in the question.
John Gietzen
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!
burnt1ce
+6  A: 

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;
Ray
Awesome, great answer!
burnt1ce