【发布时间】:2013-12-04 23:07:43
【问题描述】:
我定义了我的类,我的字段 pog_02integer 和 pog_03smallint 是整数,可以有空值(int?)
public class v_cCfgDeclaraciones {
public string pog_idcotizacion {get;set;}
public string pog_01varchar {get;set;}
public int? pog_02integer {get;set;}
public int? pog_03smallint {get;set;}
public DateTime? pog_04date {get;set;}
}
如何返回“整数”而不是 System.DBNull? 我试试这个,但我找不到返回“整数”的方法我刚刚返回 System.DBNull 如果我删除“?”在字段的名称中作为一个整体识别但不能分配空值。我想帮我解决这个问题,我可以在哪里用“?”定义字段我识别整数数据类型而不是 System.DBNull
foreach (System.Data.DataRow dr in dt.Rows){
object o = Activator.CreateInstance(iSingleType);
foreach (System.Reflection.PropertyInfo Registro in proRegistro){
if ((Registro.PropertyType.Namespace != "System.Collections.Generic") && (AtributoLectura(Registro.GetCustomAttributes(true)))){
TipoDato = Registro.PropertyType.Name;
if (TipoDato == "Nullable`1") {
string v = dr[Registro.Name.ToUpper()].GetType().FullName;
int i = v.IndexOf('.');
int l = v.Length - i;
TipoDato = v.Substring(i, l);
}
switch (TipoDato){
case "Char":
case "String":
break;
case "int": case "integer"
【问题讨论】: