Linq Contient une valeur dans la liste
difficile pour moi d'expliquer cela, mais j'espère un peu de code pour vous aider:
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)));
}
ce que je veux faire, si g.GamingProperties.Software
contient l'un des Guid de softChannels, puis l'ajouter. peut-être un autre approace sera meilleur... des suggestions ?
p.s je sais que la ligne ne fonctionne pas, j'ai mis le code que pour en faciliter la compréhension de ce dont j'ai besoin.
EDIT:
je pense que j'ai résolu:
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())));
}
si quelqu'un voit quelque chose de mal à cela, s'il vous plaît laissez-moi savoir.
qu'est-ce exactement ne fonctionne pas et ce d'erreur que vous obtenez?
Ce type est
chaîne (contenant un guid)
Ce type est
g.GamingProperties.Software
?chaîne (contenant un guid)
OriginalL'auteur Dementic | 2011-07-18
Vous devez vous connecter pour publier un commentaire.
Vous voulez vérifier si
Any()
de lasoftChannels
sont contenues:En fait, vous pouvez même écrire
OriginalL'auteur SLaks