Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite like operator doesn't work with special symbols #399

Open
dvladimirovich opened this issue May 31, 2017 · 8 comments
Open

SQLite like operator doesn't work with special symbols #399

dvladimirovich opened this issue May 31, 2017 · 8 comments

Comments

@dvladimirovich
Copy link

I have an app which works with SQLite as data store. There is an issue when I'm using context search. If I use simple phrases BLToolkit converts it in LIKE '%<search string>%' and everything works fine. But I want to use special characters as _ to have an ability do search if I've forgotten what char must be here (e.g. when name is written in different languages). And when I print string like: _ванов in my search field BLToolkit generates next query:
LastQuery.txt
And it uses ESCAPE~ for _ symbol. As a result it can't find anything...
How could I resolve this problem?

@ili
Copy link
Collaborator

ili commented May 31, 2017

This by design, by default string.Contains() escapes special symbols, use Sql.Like() extension, it should not escape

@dvladimirovich
Copy link
Author

There is a little problem. I'm using layered approach in my app, so UI layer knows nothing about others...
And I pass Expression tree predicate not simple sql

@dvladimirovich
Copy link
Author

Is there some flag to turn off escaping? Or could you give me some advice on how to resolve this problem?

@ili
Copy link
Collaborator

ili commented Jun 3, 2017

@dvladimirovich heh... really have no other idea :(

@jogibear9988
Copy link

You could rewrite your Expression Tree befor handing over to linq2db. And replace every contains with Sql.like

@dvladimirovich
Copy link
Author

Oh, I see...I suspected that I would have to do just that. And I did not want to do this, but I had to...

@jogibear9988
Copy link

i think with expressionvisitor it should not be a big task, see https://stackoverflow.com/questions/17728188/rewrite-expression-to-replace-list-contains-with-custom-method

@dvladimirovich
Copy link
Author

Yeah, I've already had such experience in rewriting Expression trees using expression visitor=)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants