Editor - .NET Select Query.Where use NOT IN (or IN) for Options

Editor - .NET Select Query.Where use NOT IN (or IN) for Options

michaelnmichaeln Posts: 8Questions: 4Answers: 0
edited August 2016 in Free community support

I am following the sample code here [ https://editor.datatables.net/manual/net/joins ] to populate the Select data

Sample code:

new Field("users.site")
    .Options("sites", "id", "name", q => q.Where("name", "L%", "LIKE") );

I am trying to select sites that is NOT IN("London", "New York"). I tried

new Field("users.site")
    .Options("sites", "id", "name", q => q.Where("name", "("London", "New York")", "NOT IN") );

and

or try something with IN

new Field("users.site")
    .Options("sites", "id", "name", q => q.Where("name", "("Seattle", "Chicago" )", "IN") );

and

I try escape using double quote or backslash.

None of them work.

Does IN or NOT IN work with Query.Where ?

Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,958Questions: 1Answers: 10,759 Site admin
    Answer ✓

    Your second one is very close, but you need to also pass in the fourth parameter to tell DataTables to not bind the values:

    new Field("users.site")
        .Options("sites", "id", "name", q => q.Where("name", "('London', 'New York')", "NOT IN") );
    

    See the WHERE condition documentation for more details.

    Allan

This discussion has been closed.