【发布时间】:2015-06-03 11:07:34
【问题描述】:
我尝试将两个集合合二为一。如果我的第二个是空的,我只需要一个空值,这是我的代码(如果com 不为空,则正确)
var tmp = List{ Elem {long UserID; string tmpContent} };
var com = List{ Comment{long UserID; string Content} } ;
var res = from t in tmp
group t by t.UserID into g
join c in com on g.Key equals c.UserID
select new AnswerSet(new List<Answer>(g), c.Content);
我想得到AnswerSet(g, Content) 或AnswerSet(g, null) 的问题,我猜是g.Key equals c.UserID 当com 为空时
【问题讨论】:
-
stackoverflow.com/a/4739738/397817 DefaultIfEmpty()?
标签: c# linq windows-store-apps