/// <summary> /// Set the Property definition object using the /// column information returned from the schema /// </summary> /// <param name="columnDefinition"> /// Column Definition information returned from the schema /// </param> /// <param name="foreignKeys"></param> /// <param name="isPrimaryKey"> /// Defines whether or not we are dealing with the primary key /// </param> /// <returns>Completed Property definition</returns> private IPropertyDefinition SetPropertyDefinition( DataRow columnDefinition, DataTable foreignKeys, bool isPrimaryKey) { PropertyDefinition propertyDefinition = new PropertyDefinition(); //set the name and full name to the column name propertyDefinition.Name = columnDefinition["COLUMN_NAME"].ToString(); propertyDefinition.FullName = columnDefinition["COLUMN_NAME"].ToString(); //set the nullable value propertyDefinition.Nullable = Convert.ToBoolean(columnDefinition["IS_NULLABLE"]); //set the max length of the data if (string.IsNullOrWhiteSpace( columnDefinition["CHARACTER_MAXIMUM_LENGTH"].ToString()) == false) { propertyDefinition.Size = Convert.ToInt32(columnDefinition["CHARACTER_MAXIMUM_LENGTH"]); } //Check if the scale is set and add it to the property definition if (string.IsNullOrWhiteSpace(columnDefinition["NUMERIC_SCALE"].ToString()) == false) { propertyDefinition.NumericScale = Convert.ToInt32(columnDefinition["NUMERIC_SCALE"]); } //Check if the Precision is set and add it to the property definition if (string.IsNullOrWhiteSpace(columnDefinition["NUMERIC_PRECISION"].ToString()) == false) { propertyDefinition.NumericPrecision = Convert.ToInt32(columnDefinition["NUMERIC_PRECISION"]); } //***********IMPORTANT STEP*************** //Convert the Data Type returned from the ole db schema to a .Net Data Type propertyDefinition.PropertyType = DataTypeConverter.OleDbToSystem( columnDefinition["DATA_TYPE"]).ToString(); propertyDefinition.MaxOccurs = 1; propertyDefinition.MinOccurs = 1; propertyDefinition.IsPrimaryKey = isPrimaryKey; //set the required action if no default value is specified and the field is not nullable if (Convert.ToBoolean(columnDefinition["IS_NULLABLE"]) == false && Convert.ToBoolean(columnDefinition["COLUMN_HASDEFAULT"]) == false) { propertyDefinition.RequiredInActionInput = true; } else { propertyDefinition.RequiredInActionInput = false; } //set default properties for supported actions //Note: these may differ based on the connector and user accessability to data fields propertyDefinition.UsedInActionInput = true; propertyDefinition.UsedInQuerySelect = true; propertyDefinition.UsedInQueryConstraint = true; propertyDefinition.UsedInActionOutput = true; propertyDefinition.UsedInLookupCondition = true; propertyDefinition.UsedInQuerySequence = true; propertyDefinition.Description = SetPropertyDescription(columnDefinition, foreignKeys); return(propertyDefinition); }