Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以使用 simple.data 查询一个表,该表的表名是从其他地方传入的。
例如:
string tableToUse = "MyTable"; var test = db.tableToUse.All();
是的,您可以将字符串索引器用于对象名称而不是动态属性:
string tableToUse = "MyTable"; var test = db[tableToUse].All();
这也适用于列名,所以你可以这样做:
var table = "MyTable"; var keyColumn = "Id"; int id = 42; var entity = db[table].Find(db[table][keyColumn] == id);