pardie
pardie

Reputation: 509

Remove NULL values from ServiceStack dynamic result set

I'm trying to remove some weird NULL result from my ServiceStack dictionary query:

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

the results I get is:

[
   {
      "ID": 41,
      "IDLIC": 1,
      "FLGPREF": {
         "__type": "System.DBNull, mscorlib"
      },
      "PROT": {
         "__type": "System.DBNull, mscorlib"
      },
      "NOTE1": "just the note 1",
      "NOTE2": "just the note 2"
   }
]

I would like to remove the NULL FLGPREF and PROT fields from the output. Is there a way to do it without using Dapper?

Thank you.

Upvotes: 1

Views: 92

Answers (1)

labilbe
labilbe

Reputation: 3584

var results = Db.SqlList<Dictionary<string, object>>("SELECT * FROM TableName WHERE PROT IS NOT NULL OR FLGPREF IS NOT NULL");

Upvotes: 1

Related Questions