0

Using Simple.Data how can I pass multiple values to a query?

Example generated SQL:

SELECT a,b,c
FROM GreatTable
WHERE x in (1,2,3)

Join support would be nice, too.

Does Simple.Data allow this sort of thing?

casperOne
  • 73,706
  • 19
  • 184
  • 253
Ronnie Overby
  • 45,287
  • 73
  • 267
  • 346

1 Answers1

3

If you have no gaps in your values e.g. 1,2,3,4 then use:-

var list = db.GreatTable.FindAllByX(1.to(4));

this produces a where x BETWEEN 1 AND 4

Otherwise if you have gaps in your range, e.g. 1,2,4,6 then use an integer array:-

var list = db.GreatTable.FindAllByX(new[] { 1, 2, 4, 6 });

this produces a where x IN (1,2,4,6)

Rippo
  • 22,117
  • 14
  • 78
  • 117