Reputation: 28545
Im using linq to sql
i have a Documents table
and a FavouriteDocuments table
FavouriteDocuments table has a documentsID fk and a ProjectID fk.
given the ProjectID how do i get all the documents(from the documents table) that are a FavouriteDocument for that particular project.
thanks
Upvotes: 3
Views: 748
Reputation: 172606
Try this:
public static Document[] GetFavouriteDocumentsForProject(int projectId)
{
using (var db = new MyContext())
{
return
(from favourite in db.FavouriteDocuments
where favourite.ProjectID == projectId
select favourite.Document).ToArray();
}
}
I hope this helps.
Upvotes: 2