.Net Editor how to add raw Sql

.Net Editor how to add raw Sql

klymov.inekonklymov.inekon Posts: 13Questions: 1Answers: 0

Hello. Is there any way to add raw sql to editor instance?
I want to add custom where, but I can't write it in existed Where function, because where condition written in other source.
I've tried to use it like this

string whereCondition = "DB_ID='MAM'" // this string only for example
editor.Where(whereCondition,"","")

but it doesn't work. I have an error.
I think parse this condition but I'm not sure it will be simple.

Replies

  • allanallan Posts: 64,016Questions: 1Answers: 10,555 Site admin

    Generally no as the libraries need to understand what is happening. However, for a WHERE condition there is a lot more flexibility. If you have a look at the documentation here you'll see how you can create complex conditions by using a closure function.

    Allan

  • klymov.inekonklymov.inekon Posts: 13Questions: 1Answers: 0

    Thanks Allan.
    Make it like this and it works

    editor.Where(s =>
    {
        s.Where(whereCondition , "", "", false);
    }); 
    
  • allanallan Posts: 64,016Questions: 1Answers: 10,555 Site admin

    Just make sure you aren't using front end submitted data in whereCondition when doing it like that. Otherwise you are open to an SQL injection attack!

    Allan

Sign In or Register to comment.