public void Map(ClassMappingBase classMap, PropertyInfo property) { if (property.DeclaringType != classMap.Type || !(classMap is ClassMapping)) return; var version = new VersionMapping { Name = property.Name, }; version.SetDefaultValue("Type", GetDefaultType(property)); version.AddDefaultColumn(new ColumnMapping { Name = property.Name }); if (IsSqlTimestamp(property)) { version.Columns.Each(x => { x.SqlType = "timestamp"; x.NotNull = true; }); version.UnsavedValue = null; } ((ClassMapping)classMap).Version = version; }
public void Map(ClassMappingBase classMap, Member member) { if (!(classMap is ClassMapping)) return; var version = new VersionMapping { ContainingEntityType = classMap.Type, }; version.Set(x => x.Name, Layer.Defaults, member.Name); version.Set(x => x.Type, Layer.Defaults, GetDefaultType(member)); var columnMapping = new ColumnMapping(); columnMapping.Set(x => x.Name, Layer.Defaults, member.Name); version.AddColumn(Layer.Defaults, columnMapping); SetDefaultAccess(member, version); if (IsSqlTimestamp(member)) { version.Columns.Each(column => { column.Set(x => x.SqlType, Layer.Defaults, "timestamp"); column.Set(x => x.NotNull, Layer.Defaults, true); }); version.Set(x => x.UnsavedValue, Layer.Defaults, null); } ((ClassMapping)classMap).Set(x => x.Version, Layer.Defaults, version); }
public void Map(ClassMappingBase classMap, Member member) { if (!(classMap is ClassMapping)) return; var version = new VersionMapping { Name = member.Name, ContainingEntityType = classMap.Type, }; version.SetDefaultValue("Type", GetDefaultType(member)); version.AddDefaultColumn(new ColumnMapping { Name = member.Name }); if (member.IsProperty && !member.CanWrite) version.Access = cfg.GetAccessStrategyForReadOnlyProperty(member).ToString(); if (IsSqlTimestamp(member)) { version.Columns.Each(x => { x.SqlType = "timestamp"; x.NotNull = true; }); version.UnsavedValue = null; } ((ClassMapping)classMap).Version = version; }
public void ShouldWriteColumns() { var mapping = new VersionMapping(); mapping.AddColumn(Layer.Defaults, new ColumnMapping("Column1")); writer.VerifyXml(mapping) .Element("column").Exists(); }
public void ShouldWriteColumns() { var mapping = new VersionMapping(); mapping.AddColumn(new ColumnMapping { Name = "Column1" }); writer.VerifyXml(mapping) .Element("column").Exists(); }
public bool Equals(VersionMapping other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(base.Equals(other) && Equals(other.ContainingEntityType, ContainingEntityType)); }
void SetDefaultAccess(Member member, VersionMapping mapping) { var resolvedAccess = MemberAccessResolver.Resolve(member); if (resolvedAccess != Access.Property && resolvedAccess != Access.Unset) { // if it's a property or unset then we'll just let NH deal with it, otherwise // set the access to be whatever we determined it might be mapping.Set(x => x.Access, Layer.Defaults, resolvedAccess.ToString()); } if (member.IsProperty && !member.CanWrite) mapping.Set(x => x.Access, Layer.Defaults, cfg.GetAccessStrategyForReadOnlyProperty(member).ToString()); }
VersionMapping IVersionMappingProvider.GetVersionMapping() { var mapping = new VersionMapping(attributes.CloneInner()); mapping.ContainingEntityType = entity; if (!mapping.IsSpecified(x => x.Name)) mapping.SetDefaultValue(x => x.Name, property.Name); if (!mapping.IsSpecified(x => x.Type)) mapping.SetDefaultValue(x => x.Type, property.PropertyType == typeof(DateTime) ? new TypeReference("timestamp") : new TypeReference(property.PropertyType)); if (!mapping.IsSpecified(x => x.Column)) mapping.SetDefaultValue(x => x.Column, property.Name); return mapping; }
public virtual void Visit(VersionMapping versionMapping) { }
public override void Visit(VersionMapping versionMapping) { versionMapping.AcceptVisitor(this); }
public virtual void ProcessVersion(VersionMapping mapping) { }
public void CreateDsl() { mapping = new VersionMapping(); inspector = new VersionInspector(mapping); }
public VersionInspector(VersionMapping mapping) : base(mapping.Columns) { this.mapping = mapping; propertyMappings.Map(x => x.Nullable, "NotNull"); }
public VersionInspector(VersionMapping mapping) { this.mapping = mapping; propertyMappings.AutoMap(); }
public bool Equals(VersionMapping other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return base.Equals(other) && Equals(other.ContainingEntityType, ContainingEntityType); }