public static int? ToInt2(this object o) { int? r = null; if (o == null || o == DBNull.Value) return r; if (o.ToString() == "") return r; return (int)o.ChangeType(typeof(int)); }
public static int ToInt(this object o) { if (o == null || o == DBNull.Value) return 0; return (int)o.ChangeType(typeof(int)); }
public static int ToInt(this object o) { if (o == null || o == DBNull.Value) return 0; var s = o as string; if (s != null) return s.ToInt(); return (int)o.ChangeType(typeof(int)); }
public static object ChangeType(this object v, EdmPrimitiveTypeKind t) { return v.ChangeType(t.ToClrType()); }