title: ServiceStack Ormlite - Postgres serializing Date property with MaxDate to JsonB
body: <p>I have a complex object which I save to a JsonB field in postgres using Ormlite.
  One of the property is a DateTime and is set to DateTime.Max.</p>
  
  <p>Retrieving the object from Postgres the DateTime property value is set to DateTime.Min value </p>
  
  <pre><code>01/01/0001 00:00:00
  </code></pre>
  
  <p>Not sure if this is a bug with Ormlite or the json serializer.</p>
  
  <p>Code snippet to replicate </p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          var item = new LicenseCheckTemp();
          item.Body = new CheckHistory();
          item.Body.List.Add(new ItemHistory() {AddedOn = DateTime.MaxValue, Note = "Test"});
  
          var factory = GetFactory(ConfigurationManager.AppSettings["PostgresConnectionString"]);
          using (var db = factory.OpenDbConnection())
          {
              db.CreateTableIfNotExists&lt;LicenseCheckTemp&gt;();
              db.Save(item);
          }
  
          using (var db = factory.OpenDbConnection())
          {
            var items =  db.Select&lt;LicenseCheckTemp&gt;();
  
              foreach (var licenseCheck in items.OrderBy(x=&gt;x.Id))
              {
                  if (licenseCheck.Body != null &amp;&amp; licenseCheck.Body.List.Any())
                  {
                      foreach (var itemHistory in licenseCheck.Body.List)
                      {
                          Console.WriteLine($"{itemHistory.AddedOn} :  Note {itemHistory.Note}");
                      }
  
                  }
  
              }
          }
  
          Console.ReadKey();
  
  
      }
  
  
      public static IDbConnectionFactory GetFactory(string connection)
      {
          var factory = new OrmLiteConnectionFactory(connection,
             PostgreSqlDialect.Provider);
  
          factory.DialectProvider.NamingStrategy = new OrmLiteNamingStrategyBase();
  
          return factory;
      }
  }
  
  public class LicenseCheckTemp
  {
      [AutoIncrement]
      public int Id { get; set; }
  
      [CustomField("json")]
      public CheckHistory Body { get; set; }
  }
  
  public class CheckHistory
  {
      public List&lt;ItemHistory&gt; List { get; set; } = new List&lt;ItemHistory&gt;();
  }
  
  public class ItemHistory
  {
      public string Note { get; set; }
  
      public DateTime AddedOn { get; set; }
  
  }
  </code></pre>