-1

My code already gets the table without containing a string. How can I get a list without containing a list of strings? I want to get the result of SELECT * FROM table WHERE column NOT IN ('x' ,'y');

public IEnumerable<keyart1> Get(string keyword)
{
    List<keyart1> keylist;
    using (dbEntities5 entities = new dbEntities5())
    {

        keylist = entities.keyart1.Where(e => e.keyword != keyword).ToList();
        var result = keylist.Distinct(new ItemEqualityComparer());
        return result;
    }
}
Jack Moody
  • 1,590
  • 3
  • 21
  • 38
  • Which part do you need help with? Do you want to know how to select from a list where the keyword is not in a list of items? – haldo Apr 08 '19 at 17:26
  • i want to select the whole table where the column keywords doesn't contain x,y,z. – Puscasu Andrei Apr 08 '19 at 17:33
  • 1
    See the answers here https://stackoverflow.com/questions/183791/how-would-you-do-a-not-in-query-with-linq – Jasen Apr 08 '19 at 17:42

1 Answers1

0

I think i found the answer if anybody interested

public IEnumerable<keyart1> Get([FromUri] string[] keyword1)
{
    List<keyart1> keylist;
    List<IEnumerable<keyart1>> ll;
    using (dbEntities5 entities = new dbEntities5())

    {
        ll = new List<IEnumerable<keyart1>>();
        foreach (var item in keyword1)
        {
            keylist = entities.keyart1.Where(e => e.keyword != item).ToList();
            var result = keylist.Distinct(new ItemEqualityComparer());
            ll.Add(result);
        }
        var intersection = ll.Aggregate((p, n) => p.Intersect(n).ToList());
       return intersection; 
    }
}