With DO.Net 3.8.*, we could use the attribute [SqlType(SqlType.Text)] to specify we wanted the underlying column in generated table to be of type "ntext". Is there an equivalent with DO 4? This thread was imported from our support forum. The original discussion may contain more detailed answer. |
Hello olorin, In order to map string (or binary) field to SQL column we analyze the value of Length property of Field attribute:
[Field] public string Name {get; set;} we create SQL column of nvarchar type, with max available length. For MS SQL Server it is equal to 4000.
[Field(Length = 100)] public string Name {get; set;} we create SQL column of nvarchar type, with specified Length (100 in this case).
[Field(Length = 4001)] public string Name {get; set;} we create SQL column of nvarchar(max) type. nvarchar(max) type is the same as ntext type in MS SQL Server 2000. In order to always get nvarchar(max) type for a field and to be independent of concrete storage provider properties (different database servers have different max available column length for nvarchar type) you may specify length in this way: [Field(Length = Int32.MaxValue)] public string Name {get; set;} Hope this helps. |