Seems to be a common problem. For the answer, I'm looking for the most efficient way to call a secondary list, based on values in a primary list.
I have a list of Posts, and a list of Comments. Each comment has a field called ItemID.
Whenever I load a set of posts, I need to get all the comments for those posts. Sometimes, this could be as many as 200 posts, resulting in 1000 or more comments.
Theoretically, I could build a CAML search statement from the ID's of all posts, like this:
foreach(SPListItem item in returnedList)
{
string CAML += string.Format("<Or><Eq><FieldRef Name=\"ItemID\" /><Value Type=\"Number\">{0}</Value></Eq></Or>",item.ID.ToString())
}//Just an example, not 100% accurate
I could also use a Join Statement in my Query.
I'm not great with SharePoint Join. It seems like this might be superior because I'm doing one call instead of two. Which method is superior? If I call both lists with a Join, do I get two SPListItemCollections, or are they returned together?