SQL Data Reader - handling Null column values

前端 未结 27 2500
甜味超标
甜味超标 2020-11-22 08:53

I\'m using a SQLdatareader to build POCOs from a database. The code works except when it encounters a null value in the database. For example, if the FirstName column in the

27条回答
  •  Happy的楠姐
    2020-11-22 09:23

    We use a series of static methods to pull all of the values out of our data readers. So in this case we'd be calling DBUtils.GetString(sqlreader(indexFirstName)) The benefit of creating static/shared methods is that you don't have to do the same checks over and over and over...

    The static method(s) would contain code to check for nulls (see other answers on this page).

提交回复
热议问题