private DataRelation CreateRelation(DataTable childTable, DataTable parentTable, DataColumn fkColumn, RelationPropertyAttribute relationPropertyAttribute) { string relationName = fkColumn.ColumnName; if (!string.IsNullOrEmpty(relationPropertyAttribute.RelationName)) { relationName = relationPropertyAttribute.RelationName; } if (childTable.DataSet.Relations.Contains(relationName)) { return(childTable.DataSet.Relations[relationName]); } else { DataRelation dataRelation = new DataRelation(relationName, parentTable.PrimaryKey[0], fkColumn, false); childTable.DataSet.Relations.Add(dataRelation); return(dataRelation); } }
private DataRelation CompleteDataRelationStructure(DataSet dataSet, DataTable parentTable, string childrenTableName, Type childrenType, PropertyInfo property, RelationPropertyAttribute relationPropertyAttribute) { DataTable childrenTable = GetDataTable(dataSet, childrenTableName); CompleteDataTableStructure(null, childrenType, childrenTable); DataColumn parentDataColumn = CompleteParentDataColumn(childrenTable, property, relationPropertyAttribute, parentTable.PrimaryKey[0].DataType); return(CreateRelation(childrenTable, parentTable, parentDataColumn, relationPropertyAttribute)); }