Pkira
6/27/2016 - 3:51 PM

LINQ

LINQ

foreach (var key_g in lstSearchKeyword.GroupBy(x => x.GroupId))
{
    int group_id = (int)key_g.First().GroupId;
    List<string> keys_aux = new List<string>();
    List<string> nots_aux = new List<string>();

    key_g.ToList().Where(x => x.IsNot == false).ToList().ForEach(x => keys_aux.Add(x.SearchWord));
    key_g.ToList().Where(x => x.IsNot == true).ToList().ForEach(x => nots_aux.Add(x.SearchWord));

    keywords.Add(group_id, keys_aux);
    nots.Add(group_id, nots_aux);
}