private DataObject CreateDataObject(BusinessObject businessObject) { string propertyName = string.Empty; string keyPropertyName = string.Empty; string relatedPropertyName = string.Empty; string relatedObjectName = string.Empty; string relationshipName = string.Empty; DataObject dataObject = new DataObject(); string objectName = businessObject.objectName; dataObject.objectName = objectName; dataObject.objectNamespace = projectNameSpace; dataObject.tableName = objectName; dataObject.keyProperties = new List<KeyProperty>(); dataObject.dataProperties = new List<DataProperty>(); dataObject.dataRelationships = new List<DataRelationship>(); if (businessObject.dataFilter != null) dataObject.dataFilter = businessObject.dataFilter; foreach (BusinessKeyProperty businessKeyProerpty in businessObject.businessKeyProperties) { KeyProperty keyProperty = new KeyProperty(); DataProperty dataProperty = new DataProperty(); keyPropertyName = businessKeyProerpty.keyPropertyName;; keyProperty.keyPropertyName = keyPropertyName; dataProperty.propertyName = keyPropertyName; dataProperty.dataType = DataType.String; dataProperty.columnName = keyPropertyName; dataProperty.isNullable = false; dataProperty.keyType = KeyType.assigned; dataObject.keyProperties.Add(keyProperty); dataObject.dataProperties.Add(dataProperty); } foreach (BusinessInterface businessInterface in businessObject.businessInterfaces) { InterfaceInformation interfaceInfo = GetInterfaceInformation(businessInterface.interfaceName); foreach (BusinessProperty businessProperty in businessInterface.businessProperties) { propertyName = businessProperty.propertyName; if (interfaceInfo != null) { if (HasProperty(interfaceInfo, propertyName)) { DataProperty dataProperty = new DataProperty(); if (!String.IsNullOrEmpty(businessProperty.dbColumn)) dataProperty.columnName = businessProperty.dbColumn; else dataProperty.columnName = propertyName; dataProperty.propertyName = propertyName; dataProperty.dataType = GetDatatype(businessProperty.dataType); dataProperty.isNullable = businessProperty.isNullable; dataProperty.isReadOnly = businessObject.isReadOnly; if (!String.IsNullOrEmpty(businessProperty.description) != null) dataProperty.description = businessObject.description; dataObject.dataProperties.Add(dataProperty); } else { throw new Exception("Property [" + propertyName + "] not found."); } } else throw new Exception("Interface [" + businessInterface.interfaceName + "] not found."); } } foreach (BusinessRelationship businessRelationship in businessObject.businessRelationships) { DataRelationship dataRelationship = new DataRelationship(); relationshipName = businessRelationship.relationshipName; relatedObjectName = businessRelationship.relatedObjectName; if (IsRelated(relationshipName, relatedObjectName, objectName)) { dataRelationship.relatedObjectName = businessRelationship.relatedObjectName; dataRelationship.relationshipName = businessRelationship.relationshipName; dataRelationship.propertyMaps = new List<PropertyMap>(); if (businessRelationship.businessRelatedInterfaces != null) { foreach (BusinessInterface businessInterface in businessRelationship.businessRelatedInterfaces) { foreach (BusinessProperty businessRelationProperty in businessInterface.businessProperties) { InterfaceInformation interfaceInfo = GetInterfaceInformation(businessInterface.interfaceName); relatedPropertyName = businessRelationProperty.propertyName; if (interfaceInfo != null) { if (HasProperty(interfaceInfo, relatedPropertyName)) { DataProperty dataProperty = new DataProperty(); PropertyMap propertyMap = new PropertyMap(); propertyMap.relatedPropertyName = relatedPropertyName; dataProperty.propertyName = dataRelationship.relatedObjectName + "_" + relatedPropertyName; dataProperty.dataType = GetDatatype(businessRelationProperty.dataType); if (!String.IsNullOrEmpty(businessRelationProperty.dbColumn)) dataProperty.columnName = businessRelationProperty.dbColumn; else dataProperty.columnName = relatedPropertyName; dataRelationship.propertyMaps.Add(propertyMap); dataObject.dataProperties.Add(dataProperty); } else { throw new Exception("Property [" + relatedPropertyName + "] not found."); } } else throw new Exception("Interface [" + businessInterface.interfaceName + "] not found."); } } dataObject.dataRelationships.Add(dataRelationship); } } } return dataObject; }