public static object ToType(this DataRowView row, Type targetType, string columnName) { if (targetType == typeof(Int32)) { return(row.Int32(columnName)); } if (targetType == typeof(bool)) { return(row.Bool(columnName)); } if (targetType == typeof(DateTime)) { return(row.DateTime(columnName)); } if (targetType == typeof(Decimal)) { return(row.Decimal(columnName)); } if (targetType == typeof(Double)) { return(row.Double(columnName)); } if (targetType == typeof(Single)) { return(row.Single(columnName)); } return(row.String(columnName)); }