ORM Basics Adjusting SQL Data Types
  • Updated on 09 Dec 2013
  • 1 minute to read
  • Print
  • Dark
    Light

ORM Basics Adjusting SQL Data Types

  • Print
  • Dark
    Light

Using overrides to the ORMField attribute, you can set what database type is used to store a field. For more information on writing ORM types see ORM Basics .

Here is an example showing how to override for a long text field. This field will become an nvarchar(max) field in SQL.

 [ORMField(typeof(TextFieldConverter))]
[DataMember]
[WritableValue]
public string Description { get; set; }

Here is an example showing how to limit the text length of a field. This field will become an nvarchar(15) field in SQL.

 [ORMField("phone_number", 15, typeof(FixedLengthStringFieldConverter))]
[DataMember]
[WritableValue]
public string PhoneNumber { get; set; }
Was this article helpful?