2

Is it possible to query a table with simple.data that has its table name passed in from somewhere else.

for example:

string tableToUse = "MyTable";
var test = db.tableToUse.All();
Larry Lustig
  • 49,320
  • 14
  • 110
  • 160
Dave
  • 3,812
  • 5
  • 31
  • 39

1 Answers1

4

Yes, you can use a string indexer for object names instead of dynamic properties:

string tableToUse = "MyTable";
var test = db[tableToUse].All();

That works for column names too, so you can do this:

var table = "MyTable";
var keyColumn = "Id";
int id = 42;
var entity = db[table].Find(db[table][keyColumn] == id);
Mark Rendle
  • 9,274
  • 1
  • 32
  • 58