>我有以下内容:
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,
...
现在我需要添加以下内容:
var types = referenceService.Get("07");
questions.type
和types.RowKey
之间存在联系的地方
有没有办法可以链接第三个数据源,如果类型表中没有任何匹配项,则让它给出消息"无匹配类型"?我的问题是我只是不太确定如何进行下一次加入。
我相信
您可以将第一个连接的结果与第三个数据源连接起来:
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,
...
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())
select new Question.Grid {
PartitionKey = q.PartitionKey,
RowKey = q.RowKey,
Topic = t == null ? "No matching topic" : t.Title,
...
}).Union
(from a in types
join q in questions on q.type equals a.RowKey
where a.ID != null
select new Question.Grid {
PartitionKey = q.PartitionKey,
RowKey = q.RowKey,
Topic = t == null ? "No matching topic" : t.Title,
...
})