1

I'm wondering if there's a way to get "raw" results from a OrmLite query in ServiceStack.

I'll explain... I know I can use:

var results = Db.SqlList<MyModel>("SELECT * FROM TableName");

passing the model of my output results, but if I don't know it? Can I get "raw" results without know the types of the data I'm reading?

Thank you

PMerlet
  • 2,568
  • 4
  • 23
  • 39
pardie
  • 399
  • 2
  • 16

1 Answers1

1

Have a look at the support of Dynamic Result sets in OrmLite.

Where you can access an un-typed schema with a List<object>, e.g:

var results = Db.SqlList<List<object>>("SELECT * FROM TableName");

Or if you want the column names as well you can use:

var results = db.Select<Dictionary<string,object>>("SELECT * ...");

OrmLite also has a version of Dapper embedded if you prefer to access the results using dynamic instead, e.g:

IEnumerable<dynamic> results = db.Query("SELECT * FROM TableName");
mythz
  • 141,670
  • 29
  • 246
  • 390
  • @wizzy I've no idea what you mean, can you update your question and spell out exactly what you're trying to do? – mythz Sep 23 '15 at 09:49
  • Thank you very much, it seems to solve my problem! Is there a way to map NULL values returned from the query? Dynamic Result returns something like: "__type": "System.DBNull, mscorlib"; while Dapper returns nothing at all. – pardie Sep 23 '15 at 09:49
  • @wizzy still not clear on what you're asking, if you're talking about inspecting nulls with dynamic have a look at: http://stackoverflow.com/a/5768449/85785 otherwise you'll have to ask a new question. – mythz Sep 23 '15 at 10:42