Dapper Extension LIKE operator returning results in reverse order while matching string

314 Views Asked by At

I am using Dapper Extension method GetByPredicate and passing the predicate value with Like operator.

Predicates.Field<Entity>(row => row, Operator.Like, $"%{string}%")

But while matching the string pattern it is returning results in reverse order, eg: if the sql table contains rows having 'test1' and 'test2' string then for a given string 'test', it is returning results as test2 and test1.

Wondering why it is returning in reversed order.

1

There are 1 best solutions below

0
Alexander On

Relational databases usually do not guarantee order in which rows are returned. If you want you rows returned in specific order use order by clause for this purpose.