protected Guid? ConvertToGuidByHierarchicalPath(DataRow dr, string columnName, bool isRequired, char delimiter, SchemaBase mainTable) { object obj = dr[map[columnName]]; if (isRequired && (obj == null || obj == DBNull.Value)) throw new Exception("'" + map[columnName] + "' is required and cannot be left empty."); if (obj == null || obj == DBNull.Value) return null; string[] values = obj.ToString().Split(delimiter); ExpressionCondition cond = Query.True; SchemaBase currentTable = mainTable; for (int i = values.Length - 1; i >= 0; i--) { cond = cond & currentTable.ObjectName == values[i].Trim(); currentTable = currentTable.ParentSchemaBase; } ArrayList list = ConvertIEnumerableToArrayList(mainTable.LoadObjects(cond)); if (list.Count == 0) throw new Exception("Unable to find a record in the table '" + mainTable.SchemaInfo.tableName + "' where the path corresponds to '" + obj.ToString() + "'."); if (list.Count > 1) throw new Exception("Found multiple records in the table '" + mainTable.SchemaInfo.tableName + "' where the path corresponds to '" + obj.ToString() + "'."); return ((PersistentObject)list[0]).ObjectID; }
protected Guid? ConvertToGuidByObjectName(DataRow dr, string columnName, bool isRequired, SchemaBase mainTable) { object obj = dr[map[columnName]]; if (isRequired && (obj == null || obj == DBNull.Value)) throw new Exception("'" + map[columnName] + "' is required and cannot be left empty."); if (obj == null || obj == DBNull.Value) return null; string value = obj.ToString().Trim(); ArrayList list = ConvertIEnumerableToArrayList(mainTable.LoadObjects(mainTable.ObjectName == value)); if (list.Count == 0) throw new Exception("Unable to find a record in the table '" + mainTable.SchemaInfo.tableName + "' where the ObjectName = '" + value + "'."); if (list.Count > 1) throw new Exception("Found multiple records in the table '" + mainTable.SchemaInfo.tableName + "' where the ObjectName = '" + value + "'."); return ((PersistentObject)list[0]).ObjectID; }