4
其我很難解釋這一個,但我希望一些代碼將有助於:的LINQ包含值列表
var softChannels = channels.ByPath("/software/").Children.Where(c => c.StateProperties.IsActive);
var tmpGames = new List<MyCms.Content.Games.Game>();
// Get games only from active game channels
foreach (var channel in channels.ByPath("/gameslivecasinodirectcom/game-channels/").Children.Where(c => c.StateProperties.IsActive))
{
// QUESTION IS ABOUT THIS LINE
tmpGames.AddRange(oGames.AllActive.Where(g => g.StateProperties.Channels.Contains(channel.Guid) && g.GamingProperties.Software.Contains(softChannels)));
}
我想要做的是,如果g.GamingProperties.Software
包含softChannels的的GUID的一個,然後添加它。也許不同意見會更好......有什麼建議嗎?
p.s我知道該行不工作,我已經把代碼放在那裏,只是爲了方便理解我需要什麼。
編輯: 我想我已經解決了它:
var softChannels = channels.ByPath("/software/").Children.Where(c => c.StateProperties.IsActive).Select(c => c.Guid);
var tmpGames = new List<MyCms.Content.Games.Game>();
// Get games only from active game channels
foreach (var channel in channels.ByPath("/gameslivecasinodirectcom/game-channels/").Children.Where(c => c.StateProperties.IsActive))
{
tmpGames.AddRange(oGames.AllActive.Where(g => g.StateProperties.Channels.Contains(channel.Guid) && softChannels.Contains(g.GamingProperties.Software.Trim())));
}
如果有人認爲有點不妥,請讓我知道。
究竟是不是工作,你得到了什麼錯誤? – BrokenGlass
'g.GamingProperties.Software'是什麼類型? – SLaks
字符串(包含一個guid) – Dementic