I need simple search functionality in different tables through my application, so I was thinking creating a GenericFilter
class, passing a query and some conditions and return the results in some way.
Is it possible with OrmLite to return such a list, or another structure? An example would be:
var result = db.Sel???("select ID, FirstName, LastName from Customers where City='Paris'");
The result could be anything, from a DataTable
to an array
.
Thanks!
Have a look at OrmLite's support for Dynamic Result Sets which for adhoc queries you can return C# 7 tuples, a List<object>
List<List<object>> result = db.SqlList<List<object>>("SELECT ...");
Or have each row populate a Dictionary with their column names:
var results = db.SqlList<Dictionary<string,object>>("SELECT ...");
You can also use dynamic
:
var results = db.SqlList<dynamic>("SELECT ...");
Should you need it, ServiceStack has great support for populating Types to and from Dictionary Objects into any POCO Type.