Skip to content

Commit

Permalink
Map SQLServer xml columns to string properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
lajones committed Feb 23, 2016
1 parent 29a0b78 commit a8b185f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class SqlServerTypeMapper : RelationalTypeMapper
private readonly RelationalTypeMapping _uniqueidentifier = new RelationalTypeMapping("uniqueidentifier", typeof(Guid));
private readonly RelationalTypeMapping _decimal = new RelationalTypeMapping("decimal(18, 2)", typeof(decimal));
private readonly RelationalTypeMapping _time = new RelationalTypeMapping("time", typeof(TimeSpan));
private readonly RelationalTypeMapping _xml = new RelationalTypeMapping("xml", typeof(string));

private readonly Dictionary<string, RelationalTypeMapping> _simpleNameMappings;
private readonly Dictionary<Type, RelationalTypeMapping> _simpleMappings;
Expand Down Expand Up @@ -82,7 +83,8 @@ public SqlServerTypeMapper()
{ "tinyint", _tinyint },
{ "uniqueidentifier", _uniqueidentifier },
{ "varbinary", _varbinary },
{ "varchar", _varchar }
{ "varchar", _varchar },
{ "xml", _xml }
};

_simpleMappings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace E2ETest.Namespace
public byte[] varbinaryMaxColumn { get; set; }
public byte[] timestampColumn { get; set; }
public Guid? uniqueidentifierColumn { get; set; }
public string xmlColumn { get; set; }
public string typeAliasColumn { get; set; }
public byte[] binaryVaryingColumn { get; set; }
public byte[] binaryVarying133Column { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ namespace E2ETest.Namespace
entity.Property(e => e.varcharColumn).HasColumnType("varchar(1)");

entity.Property(e => e.varcharMaxColumn).HasColumnType("varchar(max)");

entity.Property(e => e.xmlColumn).HasColumnType("xml");
});

modelBuilder.Entity<MultipleFKsDependent>(entity =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace E2ETest.Namespace
public byte[] varbinaryMaxColumn { get; set; }
public byte[] timestampColumn { get; set; }
public Guid? uniqueidentifierColumn { get; set; }
public string xmlColumn { get; set; }
public string typeAliasColumn { get; set; }
[MaxLength(1)]
public byte[] binaryVaryingColumn { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ namespace E2ETest.Namespace
entity.Property(e => e.varcharColumn).HasColumnType("varchar(1)");

entity.Property(e => e.varcharMaxColumn).HasColumnType("varchar(max)");

entity.Property(e => e.xmlColumn).HasColumnType("xml");
});

modelBuilder.Entity<MultipleFKsDependent>(entity =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public void E2ETest_UseAttributesInsteadOfFluentApi()
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.geometryColumn", "geometry"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.sql_variantColumn", "sql_variant"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.xmlColumn", "xml"),
RelationalDesignStrings.UnableToScaffoldIndexMissingProperty("IX_UnscaffoldableIndex"),
SqlServerDesignStrings.DataTypeDoesNotAllowSqlServerIdentityStrategy("dbo.PropertyConfiguration.PropertyConfigurationID", "tinyint"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"),
Expand Down Expand Up @@ -199,7 +198,6 @@ public void E2ETest_AllFluentApi()
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.geometryColumn", "geometry"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.hierarchyidColumn", "hierarchyid"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.sql_variantColumn", "sql_variant"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.AllDataTypes.xmlColumn", "xml"),
RelationalDesignStrings.UnableToScaffoldIndexMissingProperty("IX_UnscaffoldableIndex"),
SqlServerDesignStrings.DataTypeDoesNotAllowSqlServerIdentityStrategy("dbo.PropertyConfiguration.PropertyConfigurationID", "tinyint"),
RelationalDesignStrings.CannotFindTypeMappingForColumn("dbo.TableWithUnmappablePrimaryKeyColumn.TableWithUnmappablePrimaryKeyColumnID", "hierarchyid"),
Expand Down

0 comments on commit a8b185f

Please sign in to comment.