public void AddRange(ColumnSchema[] value) 
		{
			for (int i = 0; (i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
//		private DatabaseSchema CreateMySqlDatabaseSchema(string connectionString)
//		{
//			DataTable schemaTables = this.GetMySqlSchema(connectionString);
//
//			DatabaseSchema di = new DatabaseSchema();
//			MySqlConnection c = new MySqlConnection(connectionString);
//			di.Name = c.Database;
//			c = null;
//
//			foreach (DataRow dr in schemaTables.Rows)
//			{
//				TableSchema ti = CreateMySqlTableSchema(dr);
//				CreateColumnSchemas(ti, connectionString, Adapdev.Data.DbType.MYSQL);
//
//				DataTable columns = this.GetMySqlColumnSchema(connectionString, ti.Name);
//
//				foreach(DataRow columnRow in columns.Rows)
//				{
//					if (columnRow["Key"] + "" == "PRI")
//					{
//						ti[columnRow["Field"].ToString()].IsPrimaryKey = true;
//					}
//					else if (columnRow["Key"] + "" == "MUL")
//					{
//						ti[columnRow["Field"].ToString()].IsForeignKey = true;
//					}
//				}
//				di.AddTable(ti);
//			}
//
//			return di;
//		}
//
		/// <summary>
		/// Creates the ColumnSchemas for a specified table
		/// </summary>
		/// <param name="ts">The TableSchema to add the ColumnSchema to</param>
		/// <param name="connectionString">The OleDb connectionstring to use</param>
		private void CreateColumnSchemas(TableSchema ts, string connectionString, Adapdev.Data.DbType databaseType)
		{
			DataTable dt = this.GetReaderSchema(connectionString, ts.Name, databaseType);
			if (!(dt == null)) 
			{
				foreach (DataRow dr in dt.Rows) 
				{
					ColumnSchema ci = new ColumnSchema();
					ci.Alias = (string) dr["ColumnName"];
					ci.AllowNulls = (bool) dr["AllowDBNull"];
					ci.DataTypeId = (int) dr["ProviderType"];
					ci.DataType = ProviderInfoManager.GetInstance().GetNameById(this.dbProviderType, ci.DataTypeId);
					ci.DefaultTestValue = ProviderInfoManager.GetInstance().GetTestDefaultById(this.dbProviderType, ci.DataTypeId);
					ci.DefaultValue = ProviderInfoManager.GetInstance().GetDefaultById(this.dbProviderType, ci.DataTypeId);
					ci.IsAutoIncrement = (bool) dr["IsAutoIncrement"];
					ci.IsForeignKey = false;
					ci.IsPrimaryKey = false;
					ci.IsUnique = (bool) dr["IsUnique"];
					ci.Length = (int) dr["ColumnSize"];
					ci.Name = (string) dr["ColumnName"];
					ci.NetType = dr["DataType"].ToString();
					ci.Ordinal = (int) dr["ColumnOrdinal"];
					ci.IsReadOnly = (bool) dr["IsReadOnly"];

					// hack because MySql has the same provider type for
					// strings and blobs, which results in blob
					// default and test values being incorrectly assigned to
					// string columns
					if((ci.DataTypeId == 252 && ci.NetType.Equals("System.String")) || ci.DataTypeId == 254)
					{
						ci.DataTypeId = 253;
						ci.DataType = ProviderInfoManager.GetInstance().GetNameById(this.dbProviderType, ci.DataTypeId);
						ci.DefaultTestValue = ProviderInfoManager.GetInstance().GetTestDefaultById(this.dbProviderType, ci.DataTypeId);
						ci.DefaultValue = ProviderInfoManager.GetInstance().GetDefaultById(this.dbProviderType, ci.DataTypeId);
					}
					ts.AddColumn(ci);
				} 
			}
		}
		public ForeignKeyAssociation(ColumnSchema columnSchema, ColumnSchema foreignColumn, TableSchema foreignTable)
		{
			this._columnSchema = columnSchema;
			this._foreignColumn = foreignColumn;
			this._foreignTable = foreignTable;
		}
Пример #4
0
		private EntityField GetEntityField(ColumnSchema column) 
		{
			foreach (EntityField field in Fields) {
				if (field.DBColumn == column.Name) {
					return field;
				}
			}
			return new EntityField();
		}
		public void Add(String key, ColumnSchema value)
		{
			Dictionary.Add(key, value);
		}
		public void Remove(ColumnSchema value) 
		{
			List.Remove(value);
		}
		public void Insert(int index, ColumnSchema value) 
		{
			List.Insert(index, value);
		}
		public int IndexOf(ColumnSchema value) 
		{
			return List.IndexOf(value);
		}
		public void CopyTo(ColumnSchema[] array, int index) 
		{
			List.CopyTo(array, index);
		}
		public bool Contains(ColumnSchema value) 
		{
			return List.Contains(value);
		}
		public int Add(ColumnSchema value) 
		{
			return List.Add(value);
		}
		public ColumnSchemaCollection(ColumnSchema[] value) 
		{
			this.AddRange(value);
		}
		/// <summary>
		/// Creates the ColumnSchemas for a specified table
		/// </summary>
		/// <param name="ts">The TableSchema to add the ColumnSchema to</param>
		/// <param name="oledbConnectionString">The OleDb connectionstring to use</param>
		public void CreateColumnSchemas(TableSchema ts, string oledbConnectionString, Adapdev.Data.DbType databaseType)
		{
			DataTable dt = this.GetReaderSchema(oledbConnectionString, ts.Name, databaseType);
			if (!(dt == null)) 
			{
				foreach (DataRow dr in dt.Rows) 
				{
					ColumnSchema ci = new ColumnSchema();
					ci.Alias = (string) dr["ColumnName"];
					ci.AllowNulls = (bool) dr["AllowDBNull"];
					ci.DataTypeId = (int) dr["ProviderType"];
					ci.DataType = ProviderInfoManager.GetInstance().GetNameById(dbProviderType, ci.DataTypeId);
					ci.DefaultTestValue = ProviderInfoManager.GetInstance().GetTestDefaultById(this.dbProviderType, ci.DataTypeId);
					ci.DefaultValue = ProviderInfoManager.GetInstance().GetDefaultById(this.dbProviderType, ci.DataTypeId);
					ci.IsAutoIncrement = (bool) dr["IsAutoIncrement"];
					ci.IsForeignKey = false;
					ci.IsPrimaryKey = false;
					ci.IsUnique = (bool) dr["IsUnique"];
					ci.Length = (int) dr["ColumnSize"];
					ci.Name = (string) dr["ColumnName"];
					ci.NetType = dr["DataType"].ToString();
					ci.Ordinal = (int) dr["ColumnOrdinal"];
					ci.IsReadOnly = (bool) dr["IsReadOnly"];
					ts.AddColumn(ci);
				} 
			}
		}
		private void RefreshFieldDBInfo(ColumnSchema column, EntityField field) 
		{
			if (field.Name == string.Empty) 
			{
				field.Name = column.Name.Replace(" ", "");
				field.ReadOnly = column.IsReadOnly;
				field.AllowNull = column.AllowNulls;
			}
			Debug.WriteLine(
				column.Name + " " + column.DataTypeId + " " + column.DataType + " " + column.NetType + " " + column.Length + " " +
				column.DefaultValue + " " + column.DefaultTestValue);
			field.DBColumn = column.Name;
			field.KeyField = column.IsPrimaryKey;
			if (field.KeyField 
				&& this.OrmConfiguration.RenameSurrogateKeys 
				&& this.OrmConfiguration.SurrogateKeyName != "")
			{
				field.Name = this.OrmConfiguration.SurrogateKeyName;
			}
			field.DBIdentity = column.IsAutoIncrement;
			field.DBReadOnly = column.IsReadOnly;
			field.DBType = GetFieldDbType(column.DataTypeId, field);
			field.Type = column.NetType.Replace("System.", "");
			//this.VBType
			field.DBSize = column.Length;
			field.DBPrecision = 8;
		}
Пример #15
0
		public void RefreshDBInfo(ColumnSchema column) {
			if (Name == string.Empty) {
				Name = column.Name.Replace(" ", "");
				ReadOnly = column.IsReadOnly;
				AllowNull = column.AllowNulls;
			}
			Debug.WriteLine(
				column.Name + " " + column.DataTypeId + " " + column.DataType + " " + column.NetType + " " + column.Length + " " +
				column.DefaultValue + " " + column.DefaultTestValue);
			DBColumn = column.Name;
			KeyField = column.IsPrimaryKey;
			DBIdentity = column.IsAutoIncrement;
			DBReadOnly = column.IsReadOnly;
			DBType = GetDbType(column.DataTypeId);
			Type = column.NetType.Replace("System.", "");
			//this.VBType
			DBSize = column.Length;
			DBPrecision = 8;
		}
Пример #16
0
		/// <summary>
		/// Adds the specified ColumnSchema
		/// </summary>
		/// <param name="c"></param>
		public void AddColumn(ColumnSchema c)
		{
			this.columns[c.Name] = c;
		}