Q:

How can I join three datasources with LINQ?

I have the following:
var questions = questionService.Details(pk, rk);
var topics = contentService.GetTitles("0006000")
                .Where(x => x.RowKey.Substring(2, 2) != "00");
model = (
    from q in questions
    join t in topics on q.RowKey.Substring(0, 4) equals t.RowKey into topics2
    from t in topics2.DefaultIfEmpty()
    select new Question.Grid {
        PartitionKey = q.PartitionKey,
        RowKey = q.RowKey,
        Topic = t == null ? "No matching topic" : t.Title,
        ...

Now I need to add the following:
var types = referenceService.Get("07");

Where there is a link between questions.type and types.RowKey
Is there a way that I can link this third data source and have it give a message "No matching type" if there is nothing that matches in the type table? My problem is I am just not so sure how to do the next join.

A:

I believe you can join the result of the first join with the third datasource:
var questions = questionService.Details(pk, rk);
var topics = contentService.GetTitles("0006000")
                .Where(x => x.RowKey.Substring(2, 2) != "00");
var  types = referenceService.Get("07");

model = (
    from q in questions
    join t in topics on q.RowKey.Substring(0, 4) equals t.RowKey into topics2
    from t in topics2.DefaultIfEmpty()
    join type in types on q.type equals type.RowKey into types2
    from type in types2.DefaultIfEmpty()
    select new Question.Grid {
        PartitionKey = q.PartitionKey,
        RowKey = q.RowKey,
        Topic = t == null ? "No matching topic" : t.Title,
        Type = type == null ? "No matching type" : type.Title,
        ...

