ToString()就行了,如果是DBNull就是Empty

解决方案 »

  1.   

    补充:
    Entity也就是customerEntity的字段有不同的数据类型,而不都是string的,比如:
    customerEntity.PostCode 数据类型为 string
    customerEntity.UserID 数据类型为 int64
    customerEntity.Birthday 数据类型为 DateTime这种情况下不能都是toString()吧?求解!
      

  2.   

    没办法了,最后还是在初始化的事情给DateTime类型初始化了一个默认的C#和SqlSqerver都认可的日期值
      

  3.   

    DateTime是struct,,用DateTime?DateTime? myDate;
    myDate = dt.Rows[0].IsNull("DateCreated") ? null : (DateTime)dt.Rows[0]["UserID"];
    也就是说这时候myDate就是可以等于null的了