Gumzle
Gumzle

Reputation: 877

servicestack.ormlite sql.in not supporting empty lists

there is a merge on github that indicates that sql.in now supports empty lists rather than producing invalid sql, but it is not working for me (SS v4).

var list = new List<string>(); //this empty list should indicate "return all"
var orders = db.Select<Order>(o => Sql.In(o.Status, list));

From this link, it appears to have been implemented, but I am still getting the following SQL:

SELECT "OrderID", "Status"
FROM "Order"
WHERE "PaymentStatus" In ()

Am I missing something?

G

Upvotes: 2

Views: 1121

Answers (1)

Rama Krshna Ila
Rama Krshna Ila

Reputation: 496

An alternative solution can be you can handle it using regular Linq Query

Service stack API

outputQuery= db.Select<DTOName>(x => x.Where(r => Sql.In(r.listId, anyList)));

Change the above query to support empty list Linq Query

outputQuery= db.Select<DTOName>().Where(s => anyList.Contains(s.listId))

if(profiles) var outputQueryWithNoerror = outputQuery.ToList();

Upvotes: 1

Related Questions