SqlKata - Dynamic Sql query builder for dotnet | Product Hunt

🎉 SqlKata is now on Product Hunt

Please upvote to support the product development

String Operations

SqlKata Query Builder provides WhereStarts, WhereEnds, WhereContains and WhereLike methods to deal with string like types.

By default all string operations are case insensitive, by applying the database LOWER() and converting the value provided to lowercase.

To override this behavior you can pass a boolean true to the last parameter caseSensitive of these methods.

new Query("Posts").WhereEnds("Title", "Book")
SELECT * FROM [Posts] WHERE LOWER([Title]) LIKE '%book'

Using the case sensitive overload

new Query("Posts").WhereStarts("Title", "Book", true)
SELECT * FROM [Posts] WHERE [Title] LIKE Book%

Using the native WhereLike method

new Query("Posts").WhereLike("Title", "Book")
SELECT * FROM "Posts" WHERE LOWER("Title") LIKE 'book'

Note: in WhereLike method, you have to put the wildcard % by yourself

You can also add an optional escape clause to all of the LIKE queries using the escapeCharacter argument:

new Query("Posts").WhereLike("Title", @"%The \% Sign%", escapeCharacter=@"\")
SELECT * FROM "Posts" WHERE LOWER("Title") LIKE '%The \% Sign%' ESCAPE '\'
Heap apparel


one email per month about tips & tricks, new features, and maybe community feedback