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 ShouldWriteColumns() { var mapping = new ManyToOneMapping(); mapping.AddColumn(new ColumnMapping()); writer.VerifyXml(mapping) .Element("column").Exists(); }
private ManyToOneMapping CreateMapping(Member member) { var mapping = new ManyToOneMapping { Member = member }; mapping.Set(x => x.Name, Layer.Defaults, member.Name); mapping.Set(x => x.Class, Layer.Defaults, new TypeReference(member.PropertyType)); var columnMapping = new ColumnMapping(); columnMapping.Set(x => x.Name, Layer.Defaults, member.Name + "_id"); mapping.AddColumn(Layer.Defaults, columnMapping); SetDefaultAccess(member, mapping); return mapping; }
protected ManyToOneMapping reference_with_column(string column) { var reference = new ManyToOneMapping(); reference.AddColumn(Layer.Defaults, new ColumnMapping("propertyColumn")); return reference; }