Database example:
Image - ImageTag - Tag
Images can have multiple tags. The relationships are set up fine and stuff but I am running into pe
You can use the DataLoadOptions class to load related objects with a query.
DataLoadOptions dlo = new DataLoadOptions();
dlo.LoadWith<Image>(image => image.ImageTags);
dlo.LoadWith<ImageTag>(imageTag => imageTag.Tags);
context.DataLoadOptions = dlo;
Just to mention - this is called the "SELECT N + 1 problem".
UPDATE
I am usually using LINQ to Entities and have not much experience with LINQ to SQL. It might be required to disable DeferredLoadingEnabled explicitly, too.
context.DeferredLoadingEnabled = false;
why not try something like:
return
from i in qry
from iTags in i.ImageTags
where tags.Contains(iTags.Tag)
select new { TagName = i.Tag.name };
That will return a Collection with only the Tag Names. I hope I'm understanding your question properly here. Hope it helps