'Is there a way to build custom expression in SqlKata for the Select/Order clause
I wanted to pass custom expression to SqlKata
The expected output is:
SELECT DISTINCT(Column1 + ' ' + Column2) FROM Table1
ORDER BY Column1 + ' ' + Column2
Solution 1:[1]
You have to use Raw expressions for cases like this one, something like
var query = db.Query("Table1")
.SelectRaw("DISTINCT(Col1 + ' ' + Col2)")
.OrderByRaw("Col1 + ' ' + ColB");
Of course be aware of SQL injection.
check https://sqlkata.com/docs/select#raw and https://sqlkata.com/docs/order#orderbyraw
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | amd |