EConvertToJsonError Timestamp Column

hi,

I use a firebird database


function TGuestService.LimitColumnGuest: TList<TGUEST>;
var
  Manager: TObjectManager;
begin
  Manager := TXDataOperationContext.Current.CreateManager(TMappingExplorer.Get('PUBLICGUEST'));
  Result := Manager.Find<TGUEST>()
            .Select(TProjections.ProjectionList
                    .Add(Linq['ID_REGISTRATION'].As_('idregistration'))
                    .Add(Linq['FULLNAME'].As_('fullname'))
                    .Add(Linq['ADDRESS'].As_('address'))
                    .Add(Linq['DATETIME_REGISTRATION'].As_('datetimeregistration'))) //<-- error this timestamp column type
            .List;
  TXDataOperationContext.Current.Handler.ManagedObjects.Add(Result);
  if Result = nil then
    raise EXDataHttpException.Create(403, 'guest not found');
end;


if without column DATETIME_REGISTRATION service works correctly, but if you include the datetime_registration column it will be an error message like this.


{
  "error": {
    "code": "TJsonTypeConverter.EConvertToJsonError",
    "message": "Cannot serialize property of type \"Variant\", with value (variant), to Json format"
  }
}


how is the right way?

thanks

Date times values in variants are indeed not serialized. In this case you would have to use a specific DTO, manually creating and filling the DTO properties for the Aurelius query.

I was looking for a way to use CAST on Aurelius, but I couldn't find it.

CAST(DATETIME_REGISTRATION AS VARCHAR(25)) AS DATETIME_REGISTRATION



Solved with this http://www.tmssoftware.biz/business/aurelius/doc/web/sql_projection.html


.Add(TProjections.Sql<string>('CAST(DATETIME_REGISTRATION AS VARCHAR(25))').As_('datetimeregistration'))



Thanks you