public void Column(string columnName) { var originalColumn = mapping.Columns.FirstOrDefault(); var column = originalColumn == null ? new ColumnMapping() : originalColumn.Clone(); column.Set(x => x.Name, Layer.Conventions, columnName); mapping.AddColumn(Layer.Conventions, column); }
public void ShouldWriteTheColumns() { var mapping = new IdMapping(); mapping.AddColumn(Layer.Defaults, new ColumnMapping("Column1")); writer.VerifyXml(mapping) .Element("column").Exists(); }
public void ShouldWriteTheColumns() { var mapping = new IdMapping(); mapping.AddColumn(new ColumnMapping { Name = "Column1" }); writer.VerifyXml(mapping) .Element("column").Exists(); }
IdMapping IIdentityMappingProvider.GetIdentityMapping() { var mapping = new IdMapping(attributes.Clone()) { ContainingEntityType = entityType }; if (columns.Count > 0) { foreach (var column in columns) { var columnMapping = new ColumnMapping(columnAttributes.Clone()); columnMapping.Set(x => x.Name, Layer.Defaults, column); mapping.AddColumn(Layer.UserSupplied, columnMapping); } } else if (HasNameSpecified) { var columnMapping = new ColumnMapping(columnAttributes.Clone()); columnMapping.Set(x => x.Name, Layer.Defaults, name); mapping.AddColumn(Layer.Defaults, columnMapping); } if (member != null) { mapping.Set(x => x.Name, Layer.Defaults, name); } mapping.Set(x => x.Type, Layer.Defaults, new TypeReference(identityType)); if (GeneratedBy.IsDirty) { mapping.Set(x => x.Generator, Layer.UserSupplied, GeneratedBy.GetGeneratorMapping()); } return(mapping); }
public void Column(string columnName) { if (mapping.Columns.UserDefined.Count() > 0) { return; } var originalColumn = mapping.Columns.FirstOrDefault(); var column = originalColumn == null ? new ColumnMapping() : ColumnMapping.BaseOn(originalColumn); column.Name = columnName; mapping.ClearColumns(); mapping.AddColumn(column); }
IdMapping IIdentityMappingProvider.GetIdentityMapping() { var mapping = new IdMapping(attributes.CloneInner()) { ContainingEntityType = entityType }; if (columns.Count > 0) { foreach (var column in columns) { mapping.AddColumn(new ColumnMapping(columnAttributes.CloneInner()) { Name = column }); } } else if (HasNameSpecified) { mapping.AddDefaultColumn(new ColumnMapping(columnAttributes.CloneInner()) { Name = name }); } if (member != null) { mapping.Name = name; } mapping.SetDefaultValue("Type", new TypeReference(identityType)); if (GeneratedBy.IsDirty) { mapping.Generator = GeneratedBy.GetGeneratorMapping(); } return(mapping); }
public void Map(ClassMappingBase classMap, Member member) { if (!(classMap is ClassMapping)) { return; } var idMapping = new IdMapping { ContainingEntityType = classMap.Type }; var columnMapping = new ColumnMapping(); columnMapping.Set(x => x.Name, Layer.Defaults, member.Name); idMapping.AddColumn(Layer.Defaults, columnMapping); idMapping.Set(x => x.Name, Layer.Defaults, member.Name); idMapping.Set(x => x.Type, Layer.Defaults, new TypeReference(member.PropertyType)); idMapping.Member = member; idMapping.Set(x => x.Generator, Layer.Defaults, GetDefaultGenerator(member)); SetDefaultAccess(member, idMapping); ((ClassMapping)classMap).Set(x => x.Id, Layer.Defaults, idMapping); }
public void ColumnsCollectionHasSameCountAsMapping() { mapping.AddColumn(new ColumnMapping()); inspector.Columns.Count().ShouldEqual(1); }