title: ServiceStack.OrmLite complex types from string field in SQL Server
body: <p>We are looking at using ServiceStack.OrmLite.SqlServer 4.0.31 connected to MSSQL 2008R2 to replace our current ORM and are having difficulty in setting up the complex type string serialization. In our old ORM these were manually mapping using auto mapper to string fields using JSON.NET so we already have our JSON in the database in columns which are VARCHAR(MAX). </p>
  
  <p>I have set the string serializer to be:</p>
  
  <pre><code>SqlServerDialect.Provider.StringSerializer = new JsonDataContractSerializer();
  </code></pre>
  
  <p>The data base type is:</p>
  
  <pre><code>public class Group
  {
      [Alias("GroupID")]
      [AutoIncrement]
      [PrimaryKey]
      public int GroupId { get; set; }
  
      [Alias("Name")]
      public string Name { get; set; }
  
      [Alias("ShortName")]
      public string ShortName { get; set; }
  
      [Alias("GroupTypeID")]
      public int GroupTypeId { get; set; }
  
      [Alias("ContactDetails")]
      public ContactDetails ContactDetails { get; set; }
  
  }
  </code></pre>
  
  <p>The contact details is:</p>
  
  <pre><code>[DataContract]
  [Serializable]
  public class ContactDetails
  {
  
      [DataMember]
      public string FirstName { get; set; }
  
      [DataMember]
      public string LastName { get; set; }
  
      [DataMember]
      public string CompanyName { get; set; }
  
      [DataMember]
      public string Title { get; set; }
  
      [DataMember]
      public string Address { get; set; }
  }
  </code></pre>
  
  <p>The object is created but none of the fields are serialised: </p>
  
  <p><img src="https://i.stack.imgur.com/py8wl.png" alt="enter image description here"></p>
  
  <p>The data in the database is as follows:</p>
  
  <pre><code>{
      "Address" : "2 Doe Street, Dublin 2",
      "Phone" : "01 4684455",
      "PhoneIsVerified" : false,
      "MobileIsVerified" : false,
      "Fax" : "01 4684455",
      "Email" : "john@doe.ie",
      "Website" : "http://www.doe.ie",
      "PropertySectionEmail" : {},
      "IsPrivate" : false
  }
  </code></pre>
  
  <p>The data in the DB looks like:</p>
  
  <p><img src="https://i.stack.imgur.com/qRur2.png" alt="enter image description here"></p>
  
  <p>I saw in github that the default field for storing for these fields was VARBINARY(MAX) so I am not sure if thats why its not working but I checked all the attributes in data annotations and there was not one I could see to specify that it was a complex type. Any ideas why this is not working?</p>