Esempio n. 1
0
        private Dictionary <string, columninfo> _getColumns(APDatabase db, APGenTable table)
        {
            DbCommand dbCmd = db.CreateSqlCommand(
                @"select
	col.colid,
	col.name as colname,
	tp.name as typename,
	tp.variable,
	col.length,
	col.xprec,
	col.xscale,
	col.isnullable,
	df.name as dfname,
	df.definition as dfvalue,
	id.is_identity
from
	syscolumns as col
	inner join systypes as tp on col.xtype = tp.xtype and tp.name <> 'sysname'
	left join sys.default_constraints as df on col.cdefault = df.object_id
	left join sys.identity_columns as id on col.colid = id.column_id and id.object_id = col.id
where col.id = object_id('{0}')
order by col.colid", table.TableName);

            Dictionary <string, columninfo> dbColumns = new Dictionary <string, columninfo>();

            using (IDataReader reader = dbCmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    int        idx  = 0;
                    columninfo data = new columninfo()
                    {
                        colid       = Convert.ToInt32(reader.GetValue(idx++)),
                        colname     = Convert.ToString(reader.GetValue(idx++)),
                        typename    = Convert.ToString(reader.GetValue(idx++)),
                        variable    = Convert.ToBoolean(reader.GetValue(idx++)),
                        length      = Convert.ToInt32(reader.GetValue(idx++)),
                        xprec       = Convert.ToInt32(reader.GetValue(idx++)),
                        xscale      = Convert.ToInt32(reader.GetValue(idx++)),
                        isnullable  = Convert.ToBoolean(reader.GetValue(idx++)),
                        dfname      = Convert.ToString(reader.GetValue(idx++)),
                        dfvalue     = Convert.ToString(reader.GetValue(idx++)),
                        is_identity = reader.IsDBNull(idx++) ? false : true,
                    };
                    data.Resolve();
                    dbColumns.Add(data.colname, data);
                }
            }
            return(dbColumns);
        }
Esempio n. 2
0
        private Dictionary <string, columninfo> _getColumns(APDatabase db, APGenTable table)
        {
            OracleCommand dbCmd = db.CreateSqlCommand(
                @"select
	column_id,
	column_name,
	data_type,
	data_length,
	nvl(data_precision, 0),
	nvl(data_scale, 0),
	nullable,
	nvl(default_length, 0),
	data_default
from user_tab_columns
where table_name = '{0}'
order by column_id", table.TableName.ToUpper()) as OracleCommand;

            dbCmd.InitialLONGFetchSize = -1;

            Dictionary <string, columninfo> dbColumns = new Dictionary <string, columninfo>(StringComparer.InvariantCultureIgnoreCase);

            using (OracleDataReader reader = dbCmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    int idx = 0;

                    columninfo data = new columninfo()
                    {
                        colid      = Convert.ToInt32(reader.GetValue(idx++)),
                        colname    = Convert.ToString(reader.GetValue(idx++)),
                        typename   = Convert.ToString(reader.GetValue(idx++)).ToLower(),
                        length     = Convert.ToInt32(reader.GetValue(idx++)),
                        xprec      = Convert.ToInt32(reader.GetValue(idx++)),
                        xscale     = Convert.ToInt32(reader.GetValue(idx++)),
                        isnullable = Convert.ToString(reader.GetValue(idx++)) == "Y",
                        dflength   = Convert.ToInt32(reader.GetValue(idx++)),
                        dfvalue    = "",
                    };
                    if (data.dflength > 0)
                    {
                        data.dfvalue = reader.GetString(idx++).Trim();
                    }
                    data.Resolve();
                    dbColumns.Add(data.colname, data);
                }
            }
            return(dbColumns);
        }
		private Dictionary<string, columninfo> _getColumns(APDatabase db, APGenTable table)
		{
			DbCommand dbCmd = db.CreateSqlCommand(
@"select
	col.colid,
	col.name as colname,
	tp.name as typename,
	tp.variable,
	col.length,
	col.xprec,
	col.xscale,
	col.isnullable,
	df.name as dfname,
	df.definition as dfvalue,
	id.is_identity
from
	syscolumns as col
	inner join systypes as tp on col.xtype = tp.xtype and tp.name <> 'sysname'
	left join sys.default_constraints as df on col.cdefault = df.object_id
	left join sys.identity_columns as id on col.colid = id.column_id and id.object_id = col.id
where col.id = object_id('{0}')
order by col.colid", table.TableName);

			Dictionary<string, columninfo> dbColumns = new Dictionary<string, columninfo>();
			using (IDataReader reader = dbCmd.ExecuteReader())
			{
				while (reader.Read())
				{
					int idx = 0;
					columninfo data = new columninfo()
					{
						colid = Convert.ToInt32(reader.GetValue(idx++)),
						colname = Convert.ToString(reader.GetValue(idx++)),
						typename = Convert.ToString(reader.GetValue(idx++)),
						variable = Convert.ToBoolean(reader.GetValue(idx++)),
						length = Convert.ToInt32(reader.GetValue(idx++)),
						xprec = Convert.ToInt32(reader.GetValue(idx++)),
						xscale = Convert.ToInt32(reader.GetValue(idx++)),
						isnullable = Convert.ToBoolean(reader.GetValue(idx++)),
						dfname = Convert.ToString(reader.GetValue(idx++)),
						dfvalue = Convert.ToString(reader.GetValue(idx++)),
						is_identity = reader.IsDBNull(idx++) ? false : true,
					};
					data.Resolve();
					dbColumns.Add(data.colname, data);
				}
			}
			return dbColumns;
		}
		private Dictionary<string, columninfo> _getColumns(APDatabase db, APGenTable table)
		{
			OracleCommand dbCmd = db.CreateSqlCommand(
@"select
	column_id,
	column_name,
	data_type,
	data_length,
	nvl(data_precision, 0),
	nvl(data_scale, 0),
	nullable,
	nvl(default_length, 0),
	data_default
from user_tab_columns
where table_name = '{0}'
order by column_id", table.TableName.ToUpper()) as OracleCommand;
			dbCmd.InitialLONGFetchSize = -1;

			Dictionary<string, columninfo> dbColumns = new Dictionary<string, columninfo>(StringComparer.InvariantCultureIgnoreCase);
			using (OracleDataReader reader = dbCmd.ExecuteReader())
			{
				while (reader.Read())
				{
					int idx = 0;

					columninfo data = new columninfo(){
						colid = Convert.ToInt32(reader.GetValue(idx++)),
						colname = Convert.ToString(reader.GetValue(idx++)),
						typename = Convert.ToString(reader.GetValue(idx++)).ToLower(),
						length = Convert.ToInt32(reader.GetValue(idx++)),
						xprec = Convert.ToInt32(reader.GetValue(idx++)),
						xscale = Convert.ToInt32(reader.GetValue(idx++)),
						isnullable = Convert.ToString(reader.GetValue(idx++)) == "Y",
						dflength = Convert.ToInt32(reader.GetValue(idx++)),
						dfvalue = "",
					};
					if (data.dflength > 0)
						data.dfvalue = reader.GetString(idx++).Trim();
					data.Resolve();
					dbColumns.Add(data.colname, data);
				}
			}
			return dbColumns;
		}