public override void ProcessManyToOne(ManyToOneMapping thisSide) { if (thisSide.OtherSide == null) { return; } // other side is always going to be a collection for a many-to-one mapping var otherSide = (ICollectionMapping)thisSide.OtherSide; // both sides have user-defined key columns... leave alone! if (otherSide.Key.Columns.HasUserDefined() && thisSide.Columns.HasUserDefined()) { return; } if (otherSide.Key.Columns.HasUserDefined()) { // only other side has user-defined columns, so we'll bring them across to this side thisSide.ClearColumns(); otherSide.Key.Columns.Each(x => thisSide.AddColumn(x.Clone())); return; } if (otherSide.Key.Columns.HasUserDefined()) { // only other side has user-defined columns, so we'll bring them across to this side thisSide.ClearColumns(); otherSide.Key.Columns.Each(x => thisSide.AddColumn(x.Clone())); return; } // the other side doesn't have any user defined columns, so we'll use the ones from this side // whether they're user defined or not. otherSide.Key.ClearColumns(); thisSide.Columns.Each(x => otherSide.Key.AddColumn(x.Clone())); }
public void Column(string columnName) { if (mapping.Columns.UserDefined.Count() > 0) { return; } var originalColumn = mapping.Columns.FirstOrDefault(); var column = originalColumn == null ? new ColumnMapping() : originalColumn.Clone(); column.Name = columnName; mapping.ClearColumns(); mapping.AddColumn(column); }