从ServiceStack动态结果集中删除NULL值

时间:2015-09-23 14:55:16

标签: servicestack ormlite-servicestack

我正在尝试从ServiceStack字典查询中删除一些奇怪的NULL结果:

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

我得到的结果是:

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

我想从输出中删除NULL FLGPREF和PROT字段。 有没有办法不使用Dapper?

谢谢。

1 个答案:

答案 0 :(得分:1)

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