Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Join on a GroupJoin

$
0
0

Hi there,

So I need to set a Join on an GroupJoin. I have googled a lot to find the answer on my problem, but i cannot find it. 

In the database i have templates. I select a template with a table joined to that with items. There are also a table with one or multiple row with files linked to the item, That is the GroupJoin I use. But now the problem is that i need to call the table (and that is always 1 not more) that is linked to table with files.

For so far i have this with a join in the groupjoin:

DataBundle = _context.DataTemplates.Join(_context.DataItems, DataTemplates => DataTemplates.Id, DataItems => DataItems.DataTemplateId, (DataTemplates, DataItems) => new { DataTemplates, DataItems })
                                   .GroupJoin(_context.DataItemFiles.Join(_context.DataTemplateUploads, DataItemFiles => DataItemFiles.DataTemplateUploadId, DataTemplateUploads => DataTemplateUploads.Id, (DataItemFiles, DataTemplateUploads) => new { DataItemFiles, DataTemplateUploads }), x => x.DataItems.Id, x => x.DataItemFiles.DataItemId, (x, DataItemFiles) => new { x.DataItems, x.DataTemplates, DataItemFiles })
                                   .Where(x => x.DataTemplates.CallName == CallName).Where(x => x.DataItems.WebsiteLanguageId == WebsiteLanguageId)
                                   .Select(x => new DataBundle()
                                   {
                                       DataItemFiles = x.DataItemFiles, //error
                                       DataItemResources = null,
                                       DataItems = x.DataItems,
                                       DataTemplateFields = null,
                                       DataTemplates = x.DataTemplates,
                                       DataTemplateUploads = x.DataTemplateUploads, //can't find, because DataTemplateUploads is linked to DataItemFiles
                                   }).ToList();

    public class DataBundle
    {
        public IEnumerable<DataItemFiles> DataItemFiles { get; set; }
        public IEnumerable<DataItemResources> DataItemResources { get; set; }
        public DataItems DataItems { get; set; }
        public IEnumerable<DataTemplateFields> DataTemplateFields { get; set; }
        public DataTemplates DataTemplates { get; set; }
        public IEnumerable<DataTemplateUploads> DataTemplateUploads { get; set; }
    }

Someone know how to solve this?


Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>