C# - Server side Where Clause is overriding client columns search

C# - Server side Where Clause is overriding client columns search

guidolsguidols Posts: 38Questions: 14Answers: 1

Hello,

I correctly have implemented the individual column searching in my table.

For some reason, I also need a where condition server side:

var editor = new Editor(db, "Main", "Main.Id")
.Model...

if (parent != null)
{
  editor = editor.Where(q => q
  .Where("Main.Test", "%" + parent + "%", "LIKE"));
}

The problem is, if I write the above code, the where clause is overriding the individual column searching.

i.e. it seems impossible to filter with the server-side where clause AND with individual column searching.

How can I fix?

Thanks!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Answer ✓

    It should be quite possible - likely it will be something to do with the condition grouping. Could you add .Debug(true) before you call .Process(...) and that will output the SQL statement that gets generated to the returned JSON. Can you show us that JSON when it is in the error condition?

    Thanks,
    Allan

  • guidolsguidols Posts: 38Questions: 14Answers: 1
    edited August 2022

    There is no error, it's just that one filter is overriding the other one.

    As you correctly said, it seems related to the grouping!

    If I just do:

    editor = editor.Where("Main.Test", "%" + parent + "%", "LIKE");

    it works.

    So it's probably a sort of bug when using grouping server-side + filtering client side.

    Thanks!

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    You probably just need to use anonymous functions to do the grouping. See the example here.

    Allan

Sign In or Register to comment.