Hello, I'll start by explaining the way the Article and Keyword table are linked. I have three tables. One named Articles, one named Keywords, and the third named KeywordsInUse. Articles and Keywords both have a one to many relationship with the KeywordsInUse table in order to create a many to many relationship between Articles and Keywords.
What I'm trying to do is, filter all the Articles based on if they contain the selected Keyword in them. So for example the user clicks on the keyword, "Dog" and all the articles with the Keyword "Dog" are listed.
Here's the logic that I think might work:
Step 1. Use LINQ to query all the ArticlesInUse records by the selected Keywords ID. Here's my code for this step:
Dim GetKeyID As Integer = lblKeywordID.Text
Dim FindKeywordConnection = (From k In AI.KeywordsInUseTables
Where k.KeywordID = GetKeyID
Select k)
This works as it should. After doing this step, I now have access to all the Article IDs that are in each of the KeywordsInUse records.
So for example, since there are 4 different records in the KeywordsInUse table that have the selected KeywordID, I now also have the 4 IDs that are linked to the Article table.
This is where I'm having a hard time. What I want to do is display all the articles by their ID. I'm not exactly sure how to do this, but here's how I think I may be able to accomplish this.
Step 2. Loop through and catch and save all the article IDs into an array.
Step 3. Then use the array of article IDs with LINQ to query all the articles by their ID.
The above steps 2 and 3 seem like they'd work, but I just don't know how to do it. My experience with arrays are limited, and I'm currently looking more into them at the time. Plus, while I've been using LINQ to Entities for a few months now, I can't really think of a way where I'd actually be able to use the "Where" clause with an array of IDs.
So to sum up, my questions are: With the above logic work with what I'm trying to accomplish? And if so, can you give me a good push in the right direction of what I need to know in order to accomplish this? Also, if it doesn't work, what can I do that will help me accomplish this?