/// <summary> /// Updates a FieldInformationCollection instance /// filling it with field data read from the db /// </summary> /// <param name="dbFields">The field collection to update</param> /// <returns></returns> public FieldInformationManager ReadTableDataFromSLXDb(FieldInformationManager dbFields) { OpenDbConnection(); var cmd = dbConnection.CreateCommand(); cmd.CommandText = DbHandler.getFieldsQueryString; cmd.CommandType = System.Data.CommandType.Text; // read the field information from the db var recSet = cmd.ExecuteReader(); if (!recSet.HasRows) throw new Exception("No field information found in the db. Check your configuration!"); // read sql info for each field while (recSet.Read()) { FieldInformation f = dbFields.InitField(recSet["TableName"].ToString(), recSet["FieldName"].ToString()); f.sqlType = recSet["SqlDataType"].ToString(); f.sqlLength = (int) recSet["SqlMaximumLength"]; } recSet.Close(); CloseConnection(); return dbFields; }
private static void ReadFieldInformationsForEntity(FieldInformationManager dbFields, XPathNavigator nav) { var tableName = nav.SelectSingleNode("//entity").GetAttribute("tableName", String.Empty); foreach (XPathNavigator property in nav.Select("//property")) { string slxType = GetSlxTypeOfXmlProperty(property); if (!String.IsNullOrEmpty(slxType)) { var propertyName = property.GetAttribute("columnName", String.Empty).ToString(); var field = dbFields.InitField(tableName.ToUpper(), propertyName.ToUpper()); field.slxType = slxType; field.slxLength = GetFieldLengthFromPropertyXml(property); } } }