Getting Dapper to return an empty string instead of a null string

前端 未结 4 624
难免孤独
难免孤独 2021-01-18 13:13

I know it\'s kind of the wrong thing to do, but I\'m dealing with a legacy codebase that has NULLS when it means empty strings and vice versa.

I can\'t immediately

4条回答
  •  感动是毒
    2021-01-18 13:56

    In short: depending how you load the data to the dapper you may get two different scenarios.

    First: Turn up your data provider layer, for example like in this post - How to return null from a Dapper query rather than default(T)?.

    Second way to try: you may modify your GetTypeDeserializer like in the following post - Change Dapper so that it maps a database null value to double.NaN

    Third and the last: it is my friendly advice to work on your previous questions acceptance rate. In this way you may increase chances of replies for your questions.

    Hope all this will help.

提交回复
热议问题