LINQ to SQL join when there aren't results
- by Boarder2
Given the following database structure
I'm trying to write a LINQ query that will return images grouped by tags it's associated with.  So far I've got this:
var images = from img in db.Images
    join imgTags in db.ImageTags on img.idImage equals imgTags.idImage
    join t in db.Tags on imgTags.idTag equals t.idTag
    where img.OCRData.Contains(searchText.Text)
    group img by new { t.TagName } into aGroup
    select new
    {
        GroupName = aGroup.Key.TagName,
        Items = from x in aGroup
        select new ImageFragment()
        {
             ImageID = x.idImage,
             ScanDate = x.ScanTime
        }
    };
Which works great.  However, I also want to return Images that do not have any tags associated with them in a group of "(Untagged)" or something.  I can't wrap my head around how I would do this without inserting a default tag for every image and that seems like generally not a very good solution.