public static Type ToBasicNetType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType) { DbTypeMapEntry entry = Find(sqlDbType); Type NetType = entry.Type; return(NetType); }
/// <summary> /// Convert TSQL type to .Net data type /// </summary> /// <param name="sqlDbType"></param> /// <returns></returns> public static Type ToNetType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType) { DbTypeMapEntry entry = Find(sqlDbType); Type NetType = entry.Type; if (NetType == typeof(Decimal)) { NetType = typeof(Nullable <Decimal>); } if (NetType == typeof(Boolean)) { NetType = typeof(bool?); } if (NetType == typeof(Int32)) { NetType = typeof(int?); } if (NetType == typeof(Int64)) { NetType = typeof(long?); } if (NetType == typeof(DateTime)) { NetType = typeof(DateTime?); } return(NetType); }
public DbTypeMapEntry(Type type, DbType dbType, Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType, System.Xml.Schema.XmlTypeCode xSchemaType) { this.Type = type; this.DbType = dbType; this.SqlDbType = sqlDbType; this.XSchemaType = xSchemaType; }
private static DbTypeMapEntry Find(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType) { object retObj = new DbTypeMapEntry(typeof(System.String), DbType.String, Microsoft.SqlServer.Management.Smo.SqlDataType.VarChar, XmlTypeCode.String); for (int i = 0; i < _DbTypeList.Count; i++) { DbTypeMapEntry entry = (DbTypeMapEntry)_DbTypeList[i]; if (entry.SqlDbType == sqlDbType) { retObj = entry; break; } } return((DbTypeMapEntry)retObj); }
/// <summary> /// Convert TSQL data type to DbType /// </summary> /// <param name="sqlDbType"></param> /// <returns></returns> public static DbType ToDbType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType) { DbTypeMapEntry entry = Find(sqlDbType); return(entry.DbType); }
public static XmlTypeCode ToXmlType(Microsoft.SqlServer.Management.Smo.SqlDataType sqlDbType) { DbTypeMapEntry entry = Find(sqlDbType); return(entry.XSchemaType); }